From patchwork Wed Mar 4 23:22:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2961 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE0A86287F for ; Thu, 5 Mar 2020 00:23:47 +0100 (CET) X-Halon-ID: 3286f990-5e6f-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 3286f990-5e6f-11ea-9f85-005056917a89; Thu, 05 Mar 2020 00:23:47 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Thu, 5 Mar 2020 00:22:44 +0100 Message-Id: <20200304232246.325384-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200304232246.325384-1-niklas.soderlund@ragnatech.se> References: <20200304232246.325384-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/7] libcamera: V4L2BufferCache: Check for hot hit first X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2020 23:23:48 -0000 Check for a hot cache hit before updating which buffer is best to evict in case no hot hit is found. Suggested-by: Jacopo Mondi Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_videodevice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 268de60bc7965f58..c495de85f26efe14 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -212,15 +212,15 @@ int V4L2BufferCache::get(const FrameBuffer &buffer) if (!entry.free) continue; - if (use < 0) - use = index; - /* Try to find a cache hit by comparing the planes. */ if (entry == buffer) { hit = true; use = index; break; } + + if (use < 0) + use = index; } if (!hit)