From patchwork Wed Mar 24 07:07:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11680 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 337BDC32E7 for ; Wed, 24 Mar 2021 07:08:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D68F668D75; Wed, 24 Mar 2021 08:08:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hLIbjgdX"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C27768D68 for ; Wed, 24 Mar 2021 08:08:17 +0100 (CET) Received: by mail-pj1-x1032.google.com with SMTP id k23-20020a17090a5917b02901043e35ad4aso650751pji.3 for ; Wed, 24 Mar 2021 00:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZP/YkVyFa4d07fX875hWeHTHDNA4NCoVHKsu7ucwRFE=; b=hLIbjgdX4DES4nihhPuE9CdDvuAkN7wCesLTq/vYREGU/A3ygRZ5pJXL1Y7S60NW7t 5toJrtlGm+c8kiPojmzlhA0UI9Lu3BgWYjw7wz7UwyZDhU+4CvrAJl+rHvIjsCkAswfv u0cRPrDNyvjxzE3EdUTbRRhtqVdsS/wCmUE1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZP/YkVyFa4d07fX875hWeHTHDNA4NCoVHKsu7ucwRFE=; b=JEj5psqdaBZc0fbRspNkK1zpiCJh/htOlpXPtz8Rj/nUiL8GS5RbinIfPpRJtM2Dfa y24kdkp/yz2ys+8lB6Bps24ZY7FYAqd0A+rD4OjS9hPJHkjehaymfSBgvpXXcYbgszXX KajO03aJydZYSw01wpdYqP7tq52g7bN034QNXLJXgxT0x/v+8SQInODJCt/3ssOQv2ti XiqPh/doeUysTvxim9qxXmdgMz/8P0cDunP5Wnl89evTOFFexhwgw6FLVKmSzF42WG2Y KF9D4gCP3IgmIZmZ9hBRweyoJ7ntk80Hq1tL2RxlpYd/QXZSsUBdHcUGxUnaPpcgZbUC eYPA== X-Gm-Message-State: AOAM533EDt+T//Ot652UnpzO5AG9UNVEHBAKnNOIveQs1PC4pTgPNb+X DEFk4eqIbUhTjwpXIw02bT3t0D6mwZYzqg== X-Google-Smtp-Source: ABdhPJxABgD4qHoB6erqlCG9+HtNnMyRWOVp8/SmwOFhGX0dhkfFwnlrj+4UW5/VCKsANU18e810vw== X-Received: by 2002:a17:902:d694:b029:e6:bc94:4931 with SMTP id v20-20020a170902d694b02900e6bc944931mr2261653ply.6.1616569692271; Wed, 24 Mar 2021 00:08:12 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7c07:24cd:c637:7fab]) by smtp.gmail.com with ESMTPSA id e63sm1246860pfe.208.2021.03.24.00.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 00:08:11 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Mar 2021 16:07:54 +0900 Message-Id: <20210324070757.3530377-6-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210324070757.3530377-1-hiroh@chromium.org> References: <20210324070757.3530377-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/8] android: CameraDevice: Return const shared_ptr& by camera() 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" CameraDevice::camera() originally returns shared_ptr. It is mandatory to make a copy by calling camera() in this way. There is no need of copying if a caller needs the reference of the camera like const shared_ptr cam = camera(). That is, it is a caller that copying is required. This changes the return type of camera() to const shared_ptr&, so that we are able to reduce one redundant copy in the above case. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 555b33e7..14e26b4d 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -43,7 +43,7 @@ public: unsigned int id() const { return id_; } camera3_device_t *camera3Device() { return &camera3Device_; } - std::shared_ptr camera() const { return camera_; } + const std::shared_ptr &camera() const { return camera_; } libcamera::CameraConfiguration *cameraConfiguration() const { return config_.get();