[{"id":33265,"web_url":"https://patchwork.libcamera.org/comment/33265/","msgid":"<whksmsgxhu2z6jntofrz3u4awak33jkljpdicbhvwzuvc2pvcd@jb445brcgs6x>","date":"2025-02-03T16:48:35","subject":"Re: [RFC PATCH v2 6/9] libcamera: base: log: Pass dynamic prefix\n\tthrough","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Thu, Jan 30, 2025 at 07:58:47PM +0000, Barnabás Pőcze wrote:\n> Use move construction to essentially pass through the string\n> returned by `Loggable::logPrefix()` to avoid an unnecessary copy.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/base/log.h | 2 +-\n>  src/libcamera/base/log.cpp   | 4 ++--\n>  2 files changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index acef24203..1fb92603f 100644\n> --- a/include/libcamera/base/log.h\n> +++ b/include/libcamera/base/log.h\n> @@ -64,7 +64,7 @@ class LogMessage\n>  public:\n>  \tLogMessage(const char *fileName, unsigned int line,\n>  \t\t   const LogCategory &category, LogSeverity severity,\n> -\t\t   const std::string &prefix = std::string());\n> +\t\t   std::string prefix = {});\n>  \t~LogMessage();\n>\n>  \tstd::ostream &stream() { return msgStream_; }\n> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> index 9415b6937..0dfdb0e9b 100644\n> --- a/src/libcamera/base/log.cpp\n> +++ b/src/libcamera/base/log.cpp\n> @@ -872,9 +872,9 @@ const LogCategory &LogCategory::defaultCategory()\n>   */\n>  LogMessage::LogMessage(const char *fileName, unsigned int line,\n>  \t\t       const LogCategory &category, LogSeverity severity,\n> -\t\t       const std::string &prefix)\n> +\t\t       std::string prefix)\n\nAren't we creating an instance here (using the std::string copy-constructor)\n\n>  \t: category_(category), severity_(severity),\n> -\t  timestamp_(utils::clock::now()), prefix_(prefix)\n> +\t  timestamp_(utils::clock::now()), prefix_(std::move(prefix))\n\nJust to move it here ?\n\n>  {\n>  \tstd::ostringstream ossFileInfo;\n>  \tossFileInfo << utils::basename(fileName) << \":\" << line;\n> --\n> 2.48.1\n>\n>","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 2CF15C3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 16:48:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 591D36859A;\n\tMon,  3 Feb 2025 17:48:39 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C7F361876\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 17:48:38 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CD298497;\n\tMon,  3 Feb 2025 17:47:26 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uS75vPQj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1738601246;\n\tbh=+DQJVT3ab0zuWcNnlA5gP1BUHF8wl3dNJFzO/gzBrgw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uS75vPQjRDObm8YjMMUNDuvizHfge6R5bVTey3YY26bTMRklnzbKmlIGnKGM1GSbK\n\ttE9q6nBYCi6Z9y1pRX52PF53itIlrSiV+R4LdcZjaw01xdv7xCeyKcSyzijRTuqh9C\n\t1gvlyXGFKdGqnEKMsF87/ch0m1+AZ7QVHL/S/B6I=","Date":"Mon, 3 Feb 2025 17:48:35 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 6/9] libcamera: base: log: Pass dynamic prefix\n\tthrough","Message-ID":"<whksmsgxhu2z6jntofrz3u4awak33jkljpdicbhvwzuvc2pvcd@jb445brcgs6x>","References":"<20250130195811.1230581-1-pobrn@protonmail.com>\n\t<20250130195811.1230581-7-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250130195811.1230581-7-pobrn@protonmail.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33273,"web_url":"https://patchwork.libcamera.org/comment/33273/","msgid":"<WkxB33M02NyypgiMQe4-ztzqHD1obH5zjweQJamYVvpEJEM2bQFCKCLSwvlmvg1u53UIObSjrRp2DQeWs62CTZDHV9VXL-F9r7pSKNHfPXw=@protonmail.com>","date":"2025-02-03T18:25:23","subject":"Re: [RFC PATCH v2 6/9] libcamera: base: log: Pass dynamic prefix\n\tthrough","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"2025. február 3., hétfő 17:48 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n\n> Hi Barnabás\n> \n> On Thu, Jan 30, 2025 at 07:58:47PM +0000, Barnabás Pőcze wrote:\n> > Use move construction to essentially pass through the string\n> > returned by `Loggable::logPrefix()` to avoid an unnecessary copy.\n> >\n> > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/base/log.h | 2 +-\n> >  src/libcamera/base/log.cpp   | 4 ++--\n> >  2 files changed, 3 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> > index acef24203..1fb92603f 100644\n> > --- a/include/libcamera/base/log.h\n> > +++ b/include/libcamera/base/log.h\n> > @@ -64,7 +64,7 @@ class LogMessage\n> >  public:\n> >  \tLogMessage(const char *fileName, unsigned int line,\n> >  \t\t   const LogCategory &category, LogSeverity severity,\n> > -\t\t   const std::string &prefix = std::string());\n> > +\t\t   std::string prefix = {});\n> >  \t~LogMessage();\n> >\n> >  \tstd::ostream &stream() { return msgStream_; }\n> > diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> > index 9415b6937..0dfdb0e9b 100644\n> > --- a/src/libcamera/base/log.cpp\n> > +++ b/src/libcamera/base/log.cpp\n> > @@ -872,9 +872,9 @@ const LogCategory &LogCategory::defaultCategory()\n> >   */\n> >  LogMessage::LogMessage(const char *fileName, unsigned int line,\n> >  \t\t       const LogCategory &category, LogSeverity severity,\n> > -\t\t       const std::string &prefix)\n> > +\t\t       std::string prefix)\n> \n> Aren't we creating an instance here (using the std::string copy-constructor)\n\nYes, but inside the function there is no copying anymore because this \"local\"\ninstance is moved into the member variable.\n\n\n> \n> >  \t: category_(category), severity_(severity),\n> > -\t  timestamp_(utils::clock::now()), prefix_(prefix)\n> > +\t  timestamp_(utils::clock::now()), prefix_(std::move(prefix))\n> \n> Just to move it here ?\n> \n> >  {\n> >  \tstd::ostringstream ossFileInfo;\n> >  \tossFileInfo << utils::basename(fileName) << \":\" << line;\n> > --\n> > 2.48.1\n> >\n> >\n>","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 DAD9AC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 18:25:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 412E56859E;\n\tMon,  3 Feb 2025 19:25:30 +0100 (CET)","from mail-4322.protonmail.ch (mail-4322.protonmail.ch\n\t[185.70.43.22])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB09461876\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 19:25:28 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"PjQnCBLO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738607127; x=1738866327;\n\tbh=C/rOkxb7UMkeoLFqUNsjNx87ec+d7B+KzLY+OfaRJ5g=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=PjQnCBLOP/iFJV7ezJtM1+PkNYrgPQIM4wXH6Y5GvBMbTC2CYmUptwJirtnEirJy+\n\tLeelifOGDB261dkaMwmtsgEceX5xyVPjBwlrVTtL1CYsAN0jUe+9RPREVwIJqJ9jPz\n\tiUrn0PXmcp85oOBE2kB17CRlm0ypFgyD+cqLWGUg2I3AXDy2aQ16EVkLmK8xjCqYXA\n\tDLuI1z/4CRtSJcOlnSCEqDjP7A5OznjXlcsD9O3sbp3FRuscbytN01c2wZ41SuCsjG\n\tD7K9n/7o476vj8oKh4bLfx5tvgtwgknx1cc0dTH59uV8UnrLrldPZF6HpwDJm9pLcA\n\tqYYzbeMOAzxGA==","Date":"Mon, 03 Feb 2025 18:25:23 +0000","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 6/9] libcamera: base: log: Pass dynamic prefix\n\tthrough","Message-ID":"<WkxB33M02NyypgiMQe4-ztzqHD1obH5zjweQJamYVvpEJEM2bQFCKCLSwvlmvg1u53UIObSjrRp2DQeWs62CTZDHV9VXL-F9r7pSKNHfPXw=@protonmail.com>","In-Reply-To":"<whksmsgxhu2z6jntofrz3u4awak33jkljpdicbhvwzuvc2pvcd@jb445brcgs6x>","References":"<20250130195811.1230581-1-pobrn@protonmail.com>\n\t<20250130195811.1230581-7-pobrn@protonmail.com>\n\t<whksmsgxhu2z6jntofrz3u4awak33jkljpdicbhvwzuvc2pvcd@jb445brcgs6x>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"5c63f8db513f3349f9dcae18269053c83649cc30","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]