[{"id":15812,"web_url":"https://patchwork.libcamera.org/comment/15812/","msgid":"<YFlMtXYnZhcwOQcC@pendragon.ideasonboard.com>","date":"2021-03-23T02:04:37","subject":"Re: [libcamera-devel] [PATCH 5/8] android: CameraDevice: Return\n\tconst shared_ptr& by camera()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Tue, Mar 23, 2021 at 10:42:23AM +0900, Hirokazu Honda wrote:\n> CameraDevice::camera() originally returns shared_ptr. It is\n> mandatory to make a copy by calling camera() in this way. There\n> is no need of copying if a caller needs the reference of the\n> camera like const shared_ptr<Camera> cam = camera(). That is, it\n\nDid you mean '&cam' there ?\n\n> is a caller that copying is required. This changes the return\n> type of camera() to const shared_ptr&, so that we are able to\n> reduce one redundant copy in the above case.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/android/camera_device.h | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> index 555b33e7..14e26b4d 100644\n> --- a/src/android/camera_device.h\n> +++ b/src/android/camera_device.h\n> @@ -43,7 +43,7 @@ public:\n> \n>  \tunsigned int id() const { return id_; }\n>  \tcamera3_device_t *camera3Device() { return &camera3Device_; }\n> -\tstd::shared_ptr<libcamera::Camera> camera() const { return camera_; }\n> +\tconst std::shared_ptr<libcamera::Camera> &camera() const { return camera_; }\n>  \tlibcamera::CameraConfiguration *cameraConfiguration() const\n>  \t{\n>  \t\treturn config_.get();","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2DEF0BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Mar 2021 02:05:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD47468D66;\n\tTue, 23 Mar 2021 03:05:21 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B9636051B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Mar 2021 03:05:19 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 97180885;\n\tTue, 23 Mar 2021 03:05:18 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wmKkoCJr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1616465118;\n\tbh=wcX3fGk0oxnK++GNS6mHtxuvh0hDCAORCahRijc6Md0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wmKkoCJrUcMbmVmKJqGEVMYgG4woG+wsLZDVeqvRutmnhUh9n7AWdoXSaQgYcKi7o\n\tw+CCAwWTwe81jVMmFvB2PMMQ4ccW7/EbZ+v2U7uMLr5iZ9G8VZDEPLjLvDjkfzoblO\n\tbYyz8Fu6b6+h6SkoSw61Ru7E/8Yy7kmjDb8lzWIw=","Date":"Tue, 23 Mar 2021 04:04:37 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YFlMtXYnZhcwOQcC@pendragon.ideasonboard.com>","References":"<20210323014226.3211412-1-hiroh@chromium.org>\n\t<20210323014226.3211412-6-hiroh@chromium.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210323014226.3211412-6-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH 5/8] android: CameraDevice: Return\n\tconst shared_ptr& by camera()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15820,"web_url":"https://patchwork.libcamera.org/comment/15820/","msgid":"<CAO5uPHPhEHdhS5_onALsS5G1AcXqqgzr0rpPKrcT4srO-d4KYA@mail.gmail.com>","date":"2021-03-23T02:34:30","subject":"Re: [libcamera-devel] [PATCH 5/8] android: CameraDevice: Return\n\tconst shared_ptr& by camera()","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent, thanks for reviewing.\n\nOn Tue, Mar 23, 2021 at 11:05 AM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Hiro,\n>\n> Thank you for the patch.\n>\n> On Tue, Mar 23, 2021 at 10:42:23AM +0900, Hirokazu Honda wrote:\n> > CameraDevice::camera() originally returns shared_ptr. It is\n> > mandatory to make a copy by calling camera() in this way. There\n> > is no need of copying if a caller needs the reference of the\n> > camera like const shared_ptr<Camera> cam = camera(). That is, it\n>\n> Did you mean '&cam' there ?\n>\n\nYes, sorry for my mistake.\n\n> > is a caller that copying is required. This changes the return\n> > type of camera() to const shared_ptr&, so that we are able to\n> > reduce one redundant copy in the above case.\n> >\n> > Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> > ---\n> >  src/android/camera_device.h | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> > index 555b33e7..14e26b4d 100644\n> > --- a/src/android/camera_device.h\n> > +++ b/src/android/camera_device.h\n> > @@ -43,7 +43,7 @@ public:\n> >\n> >       unsigned int id() const { return id_; }\n> >       camera3_device_t *camera3Device() { return &camera3Device_; }\n> > -     std::shared_ptr<libcamera::Camera> camera() const { return camera_; }\n> > +     const std::shared_ptr<libcamera::Camera> &camera() const { return camera_; }\n> >       libcamera::CameraConfiguration *cameraConfiguration() const\n> >       {\n> >               return config_.get();\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DDF2BC32E2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Mar 2021 02:34:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 981A06084F;\n\tTue, 23 Mar 2021 03:34:41 +0100 (CET)","from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com\n\t[IPv6:2a00:1450:4864:20::62c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FC3C6051B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Mar 2021 03:34:40 +0100 (CET)","by mail-ej1-x62c.google.com with SMTP id k10so24590669ejg.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 19:34:40 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"DatqD2xB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=ljA+j7UoCjFQLj3cPyeGJ0k3TT190z+z7WhalRSnu40=;\n\tb=DatqD2xBwVjp9uK5eyLFiDBdpXLjDZJe273zd5lnFBPf8PqAxOMNIerM6KT7buZXz8\n\tXuPfLHWebDvwSMj2YR33d+/ACM7WOE601oUVhqtOkbqpkHo7igBMpQX9pBSCiJaTyljL\n\tawgza5JLiKlOSRsClfJikdwn/fXp+yNJ8LZTw=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=ljA+j7UoCjFQLj3cPyeGJ0k3TT190z+z7WhalRSnu40=;\n\tb=P1L+icGNuVOjjKGihuHF+KtjVMolCbfxr8Fovx+glSEd+PEuc5uwAvtLPIWfyWfxto\n\t7EkbxLZtvQ7Kj5BBzMxpYgc+lwqNDgbLG8n/3IvjPJ/xjfbx7WNC+m0LbUCnPdWuJssa\n\t/3Ssmko+t54fL8qK4T1OpXLVlbpDVjeji2DO9TT7M9LJmvHoCfy85wAgGgdybJsdmzJr\n\tVhuliHg/9EhyCufmyKSQW5Jta0v0rA9iW/BGesJjMwH+9gIaqd/fKVbQe+nfzaqlluMA\n\thljSXQa7cDUa99HhMo98NVbT9lGx0DxjCNU8cu7dmValIH6g7i9kQb8+FZ0dgTN1TkLS\n\t763g==","X-Gm-Message-State":"AOAM530r12aHS1LtB1GDkR+/lmfylMUlp7l3F//4FHfoXKf9d7MeMYm6\n\tTqKoTJL6BixxKhVqyIxXfBOkCCycrx5vV9zeZ+1g/nGlENE=","X-Google-Smtp-Source":"ABdhPJw6bUxToJO8e8DBHiQIPfLpsQwVKArKhupm0zE5xT+Uiu9ozcMu4pW0uwDL3Iam7Uj+K1SZpc52jdIvh0WHsBc=","X-Received":"by 2002:a17:906:4801:: with SMTP id\n\tw1mr2587264ejq.475.1616466879857; \n\tMon, 22 Mar 2021 19:34:39 -0700 (PDT)","MIME-Version":"1.0","References":"<20210323014226.3211412-1-hiroh@chromium.org>\n\t<20210323014226.3211412-6-hiroh@chromium.org>\n\t<YFlMtXYnZhcwOQcC@pendragon.ideasonboard.com>","In-Reply-To":"<YFlMtXYnZhcwOQcC@pendragon.ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Tue, 23 Mar 2021 11:34:30 +0900","Message-ID":"<CAO5uPHPhEHdhS5_onALsS5G1AcXqqgzr0rpPKrcT4srO-d4KYA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 5/8] android: CameraDevice: Return\n\tconst shared_ptr& by camera()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]