[{"id":22178,"web_url":"https://patchwork.libcamera.org/comment/22178/","msgid":"<YhOKahYRhV7uwup1@pendragon.ideasonboard.com>","date":"2022-02-21T12:49:46","subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nejc,\n\nThank you for the patch.\n\nOn Sun, Feb 20, 2022 at 01:52:57AM +0100, Nejc Galof wrote:\n> Use structured bindings range-based for loops for better readability.\n\nIt looks nicer indeed !\n\n> ---\n>  src/cam/camera_session.cpp | 21 +++++++--------------\n>  1 file changed, 7 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\n> index 1bf460fa..0428b538 100644\n> --- a/src/cam/camera_session.cpp\n> +++ b/src/cam/camera_session.cpp\n> @@ -120,10 +120,7 @@ CameraSession::~CameraSession()\n>  \n>  void CameraSession::listControls() const\n>  {\n> -\tfor (const auto &ctrl : camera_->controls()) {\n> -\t\tconst ControlId *id = ctrl.first;\n> -\t\tconst ControlInfo &info = ctrl.second;\n> -\n> +\tfor (const auto &[id, info] : camera_->controls()) {\n>  \t\tstd::cout << \"Control: \" << id->name() << \": \"\n>  \t\t\t  << info.toString() << std::endl;\n>  \t}\n\nYou can now drop the curly braces.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nThere's no need to submit a v2, I'll make this small change when\napplying the patch.\n\n> @@ -131,9 +128,8 @@ void CameraSession::listControls() const\n>  \n>  void CameraSession::listProperties() const\n>  {\n> -\tfor (const auto &prop : camera_->properties()) {\n> -\t\tconst ControlId *id = properties::properties.at(prop.first);\n> -\t\tconst ControlValue &value = prop.second;\n> +\tfor (const auto &[key, value] : camera_->properties()) {\n> +\t\tconst ControlId *id = properties::properties.at(key);\n>  \n>  \t\tstd::cout << \"Property: \" << id->name() << \" = \"\n>  \t\t\t  << value.toString() << std::endl;\n> @@ -374,10 +370,7 @@ void CameraSession::processRequest(Request *request)\n>  \t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n>  \t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n>  \n> -\tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n> -\t\tconst Stream *stream = it->first;\n> -\t\tFrameBuffer *buffer = it->second;\n> -\n> +\tfor (const auto &[stream, buffer] : buffers) {\n>  \t\tconst FrameMetadata &metadata = buffer->metadata();\n>  \n>  \t\tinfo << \" \" << streamNames_[stream]\n> @@ -401,10 +394,10 @@ void CameraSession::processRequest(Request *request)\n>  \n>  \tif (printMetadata_) {\n>  \t\tconst ControlList &requestMetadata = request->metadata();\n> -\t\tfor (const auto &ctrl : requestMetadata) {\n> -\t\t\tconst ControlId *id = controls::controls.at(ctrl.first);\n> +\t\tfor (const auto &[key, value] : requestMetadata) {\n> +\t\t\tconst ControlId *id = controls::controls.at(key);\n>  \t\t\tstd::cout << \"\\t\" << id->name() << \" = \"\n> -\t\t\t\t  << ctrl.second.toString() << std::endl;\n> +\t\t\t\t  << value.toString() << std::endl;\n>  \t\t}\n>  \t}\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 50D40BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Feb 2022 12:49:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 77E9C61127;\n\tMon, 21 Feb 2022 13:49:57 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 99202610A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Feb 2022 13:49:56 +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 0E64E482;\n\tMon, 21 Feb 2022 13:49:55 +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=\"jXUx0geX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1645447796;\n\tbh=BdqJa5rCPX16rLqEPmU6Eq5fDeVGlqYHC+vMPpreBOI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=jXUx0geXyZkeMITsBHzjpK+IkI2vM0f3E5AJlq374bUSTKvCCwFQA1bCSN1splbA0\n\tyNfSgutRJ9WsJqYVtmlTms8rzdAy4q/Nwc+09wKCZNOKJYbrxmmY8JHKnGb1wdkEJN\n\t3qeaZI53Qg3Bra2Sxm6syMoy/ki1wnXJd2yMJLPU=","Date":"Mon, 21 Feb 2022 14:49:46 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nejc Galof <galof.nejc@gmail.com>","Message-ID":"<YhOKahYRhV7uwup1@pendragon.ideasonboard.com>","References":"<20220220005257.30480-1-galof.nejc@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220220005257.30480-1-galof.nejc@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22179,"web_url":"https://patchwork.libcamera.org/comment/22179/","msgid":"<YhOMNxIF+2pELkYE@pendragon.ideasonboard.com>","date":"2022-02-21T12:57:27","subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nejc,\n\nOn Mon, Feb 21, 2022 at 02:49:46PM +0200, Laurent Pinchart wrote:\n> On Sun, Feb 20, 2022 at 01:52:57AM +0100, Nejc Galof wrote:\n> > Use structured bindings range-based for loops for better readability.\n> \n> It looks nicer indeed !\n\nI forgot to mention that the patch is missing your Signed-off-by line.\nPlease see https://libcamera.org/contributing.html#submitting-patches.\nYou can use the -s option to git commit to add it. For this patch, you\ncan just reply to this e-mail with the SoB line and I'll add it locally.\n\n> > ---\n> >  src/cam/camera_session.cpp | 21 +++++++--------------\n> >  1 file changed, 7 insertions(+), 14 deletions(-)\n> > \n> > diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\n> > index 1bf460fa..0428b538 100644\n> > --- a/src/cam/camera_session.cpp\n> > +++ b/src/cam/camera_session.cpp\n> > @@ -120,10 +120,7 @@ CameraSession::~CameraSession()\n> >  \n> >  void CameraSession::listControls() const\n> >  {\n> > -\tfor (const auto &ctrl : camera_->controls()) {\n> > -\t\tconst ControlId *id = ctrl.first;\n> > -\t\tconst ControlInfo &info = ctrl.second;\n> > -\n> > +\tfor (const auto &[id, info] : camera_->controls()) {\n> >  \t\tstd::cout << \"Control: \" << id->name() << \": \"\n> >  \t\t\t  << info.toString() << std::endl;\n> >  \t}\n> \n> You can now drop the curly braces.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> There's no need to submit a v2, I'll make this small change when\n> applying the patch.\n> \n> > @@ -131,9 +128,8 @@ void CameraSession::listControls() const\n> >  \n> >  void CameraSession::listProperties() const\n> >  {\n> > -\tfor (const auto &prop : camera_->properties()) {\n> > -\t\tconst ControlId *id = properties::properties.at(prop.first);\n> > -\t\tconst ControlValue &value = prop.second;\n> > +\tfor (const auto &[key, value] : camera_->properties()) {\n> > +\t\tconst ControlId *id = properties::properties.at(key);\n> >  \n> >  \t\tstd::cout << \"Property: \" << id->name() << \" = \"\n> >  \t\t\t  << value.toString() << std::endl;\n> > @@ -374,10 +370,7 @@ void CameraSession::processRequest(Request *request)\n> >  \t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n> >  \t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n> >  \n> > -\tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n> > -\t\tconst Stream *stream = it->first;\n> > -\t\tFrameBuffer *buffer = it->second;\n> > -\n> > +\tfor (const auto &[stream, buffer] : buffers) {\n> >  \t\tconst FrameMetadata &metadata = buffer->metadata();\n> >  \n> >  \t\tinfo << \" \" << streamNames_[stream]\n> > @@ -401,10 +394,10 @@ void CameraSession::processRequest(Request *request)\n> >  \n> >  \tif (printMetadata_) {\n> >  \t\tconst ControlList &requestMetadata = request->metadata();\n> > -\t\tfor (const auto &ctrl : requestMetadata) {\n> > -\t\t\tconst ControlId *id = controls::controls.at(ctrl.first);\n> > +\t\tfor (const auto &[key, value] : requestMetadata) {\n> > +\t\t\tconst ControlId *id = controls::controls.at(key);\n> >  \t\t\tstd::cout << \"\\t\" << id->name() << \" = \"\n> > -\t\t\t\t  << ctrl.second.toString() << std::endl;\n> > +\t\t\t\t  << value.toString() << std::endl;\n> >  \t\t}\n> >  \t}\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 2B329BE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Feb 2022 12:57:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 942A2610F8;\n\tMon, 21 Feb 2022 13:57:38 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C1B0610A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Feb 2022 13:57:36 +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 06599482;\n\tMon, 21 Feb 2022 13:57:35 +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=\"btU5SD9K\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1645448256;\n\tbh=5RHtigj8c2UjEo8/9F48FRB+qNjsom2e8YiciGI/oB0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=btU5SD9K+3mSUnfuc3woiXJaQQUZLXhhbOea5wdjYddytCBlKU0B3FDNIsf6UkHKC\n\tReL2qDF3cNtKcyZ0nPl+2M5abotd9ATHC7ttlt3esT9kKQK+Pxb9453F+UNbw5QaDf\n\tw7LAROKvVgwaP+vWBQiUBiaXQvhi3ZFRfC6tjucE=","Date":"Mon, 21 Feb 2022 14:57:27 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nejc Galof <galof.nejc@gmail.com>","Message-ID":"<YhOMNxIF+2pELkYE@pendragon.ideasonboard.com>","References":"<20220220005257.30480-1-galof.nejc@gmail.com>\n\t<YhOKahYRhV7uwup1@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<YhOKahYRhV7uwup1@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22180,"web_url":"https://patchwork.libcamera.org/comment/22180/","msgid":"<CAKmrpNy2DDAV95OqTu75DW9Fv-mh9koOqk8ViKxRtuaynaXnfw@mail.gmail.com>","date":"2022-02-21T13:03:39","subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","submitter":{"id":113,"url":"https://patchwork.libcamera.org/api/people/113/","name":"Nejc Galof","email":"galof.nejc@gmail.com"},"content":"Thanks for noticing the mistake.\n\nSigned-off-by: Nejc Galof <galof.nejc@gmail.com>\n\nNejc Galof\n\nV V pon., 21. feb. 2022 ob 13:57 je oseba Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> napisala:\n\n> Hi Nejc,\n>\n> On Mon, Feb 21, 2022 at 02:49:46PM +0200, Laurent Pinchart wrote:\n> > On Sun, Feb 20, 2022 at 01:52:57AM +0100, Nejc Galof wrote:\n> > > Use structured bindings range-based for loops for better readability.\n> >\n> > It looks nicer indeed !\n>\n> I forgot to mention that the patch is missing your Signed-off-by line.\n> Please see https://libcamera.org/contributing.html#submitting-patches.\n> You can use the -s option to git commit to add it. For this patch, you\n> can just reply to this e-mail with the SoB line and I'll add it locally.\n>\n> > > ---\n> > >  src/cam/camera_session.cpp | 21 +++++++--------------\n> > >  1 file changed, 7 insertions(+), 14 deletions(-)\n> > >\n> > > diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\n> > > index 1bf460fa..0428b538 100644\n> > > --- a/src/cam/camera_session.cpp\n> > > +++ b/src/cam/camera_session.cpp\n> > > @@ -120,10 +120,7 @@ CameraSession::~CameraSession()\n> > >\n> > >  void CameraSession::listControls() const\n> > >  {\n> > > -   for (const auto &ctrl : camera_->controls()) {\n> > > -           const ControlId *id = ctrl.first;\n> > > -           const ControlInfo &info = ctrl.second;\n> > > -\n> > > +   for (const auto &[id, info] : camera_->controls()) {\n> > >             std::cout << \"Control: \" << id->name() << \": \"\n> > >                       << info.toString() << std::endl;\n> > >     }\n> >\n> > You can now drop the curly braces.\n> >\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > There's no need to submit a v2, I'll make this small change when\n> > applying the patch.\n> >\n> > > @@ -131,9 +128,8 @@ void CameraSession::listControls() const\n> > >\n> > >  void CameraSession::listProperties() const\n> > >  {\n> > > -   for (const auto &prop : camera_->properties()) {\n> > > -           const ControlId *id = properties::properties.at\n> (prop.first);\n> > > -           const ControlValue &value = prop.second;\n> > > +   for (const auto &[key, value] : camera_->properties()) {\n> > > +           const ControlId *id = properties::properties.at(key);\n> > >\n> > >             std::cout << \"Property: \" << id->name() << \" = \"\n> > >                       << value.toString() << std::endl;\n> > > @@ -374,10 +370,7 @@ void CameraSession::processRequest(Request\n> *request)\n> > >          << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n> > >          << \" (\" << std::fixed << std::setprecision(2) << fps << \"\n> fps)\";\n> > >\n> > > -   for (auto it = buffers.begin(); it != buffers.end(); ++it) {\n> > > -           const Stream *stream = it->first;\n> > > -           FrameBuffer *buffer = it->second;\n> > > -\n> > > +   for (const auto &[stream, buffer] : buffers) {\n> > >             const FrameMetadata &metadata = buffer->metadata();\n> > >\n> > >             info << \" \" << streamNames_[stream]\n> > > @@ -401,10 +394,10 @@ void CameraSession::processRequest(Request\n> *request)\n> > >\n> > >     if (printMetadata_) {\n> > >             const ControlList &requestMetadata = request->metadata();\n> > > -           for (const auto &ctrl : requestMetadata) {\n> > > -                   const ControlId *id = controls::controls.at\n> (ctrl.first);\n> > > +           for (const auto &[key, value] : requestMetadata) {\n> > > +                   const ControlId *id = controls::controls.at(key);\n> > >                     std::cout << \"\\t\" << id->name() << \" = \"\n> > > -                             << ctrl.second.toString() << std::endl;\n> > > +                             << value.toString() << std::endl;\n> > >             }\n> > >     }\n> > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 21007BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Feb 2022 13:03:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 768DB6112A;\n\tMon, 21 Feb 2022 14:03:53 +0100 (CET)","from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com\n\t[IPv6:2607:f8b0:4864:20::d2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F0109610A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Feb 2022 14:03:51 +0100 (CET)","by mail-io1-xd2e.google.com with SMTP id q8so15938508iod.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Feb 2022 05:03:51 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"UfYHY4o1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=DeX1inUmPO6Of5WHNSCGPlAb0yT9kEXYwZNIRFTL2dM=;\n\tb=UfYHY4o1D9a5VP8ILTbb7E80DlKfHaqmnCwvASi4wlj+OBt5omF2frxYWtSKwyE72J\n\tQTvo1ByvY3shVSSFgPV2xPVRK4mdGuRCz/PnWNVVFpYQhL46VK6kVlCDceWbRP8mPOxy\n\t17FQyvj+2ezbysBP5QGHzB69RTZ32kQlzD1V0VU+pvRPkGZsBtAmbPbTL0tTbPOdmylm\n\tui5zy0Rx/37xS8VO2PajL0JWdetQzSP0L/gPx5Y4huYtqiaaIqbotHL8JEgxF+HbKRz5\n\tviILV4bpOJPC+d5Iwlqwe0T7imZebN+gEC1gXSzHD7HjuFycDvwNgzZ0oRJMo8N+Gs1E\n\t7cFQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=DeX1inUmPO6Of5WHNSCGPlAb0yT9kEXYwZNIRFTL2dM=;\n\tb=3cx3yd4g1qLDlk5KkBZk07tBIS1v4/EUmP42PsYKZhHBV8BfbqOmBXzDj/xPjbIxpF\n\tj2kOHGdwQL0/bpQvNgj9IDDcW7Moi4cy6wWDd6Q4+Vt8/VdjR75QrvshtiCJq0PjoOcV\n\tLFJDTN1nH/PoVKBUjGT0cA774aoebrR7T1SHHue2gMaHII3YW+VjS1yP6+LYb7uRpDbc\n\tQJji+hGw8NEbkACl12B4w47CuQnu4I9IugwjRZb7kOd/gz1eD6PnzQCtjcPxWCu+94ni\n\tZqC7s7UTrplkusjbc6s9Xr62E/eX5+F7QwNGQNxzKuipA5cnMhYHblX7YNRCzKCZCu+V\n\t3nig==","X-Gm-Message-State":"AOAM530M2L1HPiDGEROxnQlvCLe/vKR2HCzjf3ii8p3jDzSXIfn7Uic/\n\tLn4Ha07/a8+1kidqPY1FRFq0To+p14RhlDsg7JI=","X-Google-Smtp-Source":"ABdhPJywErJV6j1kY/xQkgDZacn5iVjaSjvwH1dTi/0Dc08jwNpRxeeFH1ElrELMYjkkHA8JDW7T6Kyg3HNhgJIe/g4=","X-Received":"by 2002:a02:cd36:0:b0:314:c2e2:4606 with SMTP id\n\th22-20020a02cd36000000b00314c2e24606mr8472002jaq.28.1645448630669;\n\tMon, 21 Feb 2022 05:03:50 -0800 (PST)","MIME-Version":"1.0","References":"<20220220005257.30480-1-galof.nejc@gmail.com>\n\t<YhOKahYRhV7uwup1@pendragon.ideasonboard.com>\n\t<YhOMNxIF+2pELkYE@pendragon.ideasonboard.com>","In-Reply-To":"<YhOMNxIF+2pELkYE@pendragon.ideasonboard.com>","From":"Nejc Galof <galof.nejc@gmail.com>","Date":"Mon, 21 Feb 2022 14:03:39 +0100","Message-ID":"<CAKmrpNy2DDAV95OqTu75DW9Fv-mh9koOqk8ViKxRtuaynaXnfw@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000020956005d886dd0f\"","Subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22181,"web_url":"https://patchwork.libcamera.org/comment/22181/","msgid":"<164544901855.3903979.1567170512037115583@Monstersaurus>","date":"2022-02-21T13:10:18","subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Nejc Galof (2022-02-20 00:52:57)\n> Use structured bindings range-based for loops for better readability.\n> ---\n>  src/cam/camera_session.cpp | 21 +++++++--------------\n>  1 file changed, 7 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\n> index 1bf460fa..0428b538 100644\n> --- a/src/cam/camera_session.cpp\n> +++ b/src/cam/camera_session.cpp\n> @@ -120,10 +120,7 @@ CameraSession::~CameraSession()\n>  \n>  void CameraSession::listControls() const\n>  {\n> -       for (const auto &ctrl : camera_->controls()) {\n> -               const ControlId *id = ctrl.first;\n> -               const ControlInfo &info = ctrl.second;\n> -\n> +       for (const auto &[id, info] : camera_->controls()) {\n\nI have continually disliked '.first' and '.second' so I'm happy to see\nthis.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nI still prefer the structured bindings, but where we explicitly cast\nthe type to .first and .second does help show the type information, but\nthat can also be determined/conveyed from the return type of the\niterator/getters - so I still think this is fine.\n\n\n>                 std::cout << \"Control: \" << id->name() << \": \"\n>                           << info.toString() << std::endl;\n>         }\n> @@ -131,9 +128,8 @@ void CameraSession::listControls() const\n>  \n>  void CameraSession::listProperties() const\n>  {\n> -       for (const auto &prop : camera_->properties()) {\n> -               const ControlId *id = properties::properties.at(prop.first);\n> -               const ControlValue &value = prop.second;\n> +       for (const auto &[key, value] : camera_->properties()) {\n> +               const ControlId *id = properties::properties.at(key);\n>  \n>                 std::cout << \"Property: \" << id->name() << \" = \"\n>                           << value.toString() << std::endl;\n> @@ -374,10 +370,7 @@ void CameraSession::processRequest(Request *request)\n>              << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n>              << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n>  \n> -       for (auto it = buffers.begin(); it != buffers.end(); ++it) {\n> -               const Stream *stream = it->first;\n> -               FrameBuffer *buffer = it->second;\n> -\n> +       for (const auto &[stream, buffer] : buffers) {\n>                 const FrameMetadata &metadata = buffer->metadata();\n>  \n>                 info << \" \" << streamNames_[stream]\n> @@ -401,10 +394,10 @@ void CameraSession::processRequest(Request *request)\n>  \n>         if (printMetadata_) {\n>                 const ControlList &requestMetadata = request->metadata();\n> -               for (const auto &ctrl : requestMetadata) {\n> -                       const ControlId *id = controls::controls.at(ctrl.first);\n> +               for (const auto &[key, value] : requestMetadata) {\n> +                       const ControlId *id = controls::controls.at(key);\n>                         std::cout << \"\\t\" << id->name() << \" = \"\n> -                                 << ctrl.second.toString() << std::endl;\n> +                                 << value.toString() << std::endl;\n>                 }\n>         }\n>  \n> -- \n> 2.17.1\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 272E3BE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Feb 2022 13:10:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8405061127;\n\tMon, 21 Feb 2022 14:10:22 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DB08610A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Feb 2022 14:10:21 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E4501482;\n\tMon, 21 Feb 2022 14:10:20 +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=\"sdsUyM8D\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1645449021;\n\tbh=LpYxBfdP1+92KJWFdqTEd4+O1x6KTpFRZHE+n86bmlE=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=sdsUyM8DbyFK5iDOA+EY87OK/XcIG3gH/W5G+SbgfNu0C9I1IOpVwR+TktrQnDyO4\n\tvYpJXaz9hNW2S2/cQFo0Tq4mhlmbdcpCzzFvKoxDFQ/1UaqKZF2A65U70Uj/5zMPC0\n\t4xsQ6dXAVWTYecjH6ycnkoTDRNEBoD1kKladxado=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220220005257.30480-1-galof.nejc@gmail.com>","References":"<20220220005257.30480-1-galof.nejc@gmail.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Nejc Galof <galof.nejc@gmail.com>, libcamera-devel@lists.libcamera.org","Date":"Mon, 21 Feb 2022 13:10:18 +0000","Message-ID":"<164544901855.3903979.1567170512037115583@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] cam: Use structured bindings in\n\trange-based for loops","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>"}}]