{"id":15369,"url":"https://patchwork.libcamera.org/api/1.1/patches/15369/?format=json","web_url":"https://patchwork.libcamera.org/patch/15369/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220220005257.30480-1-galof.nejc@gmail.com>","date":"2022-02-20T00:52:57","name":"[libcamera-devel] cam: Use structured bindings in range-based for loops","commit_ref":"7a118dbdb881c38ad13de12efb023c6b78d2a57e","pull_url":null,"state":"accepted","archived":false,"hash":"1af304e913b0da2687dad778a3e65d622280b764","submitter":{"id":113,"url":"https://patchwork.libcamera.org/api/1.1/people/113/?format=json","name":"Nejc Galof","email":"galof.nejc@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15369/mbox/","series":[{"id":2934,"url":"https://patchwork.libcamera.org/api/1.1/series/2934/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2934","date":"2022-02-20T00:52:57","name":"[libcamera-devel] cam: Use structured bindings in range-based for loops","version":1,"mbox":"https://patchwork.libcamera.org/series/2934/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15369/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15369/checks/","tags":{},"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 3E52EBE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 20 Feb 2022 00:53:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 70F1E61121;\n\tSun, 20 Feb 2022 01:53:08 +0100 (CET)","from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com\n\t[IPv6:2a00:1450:4864:20::62d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A6DC8601F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 20 Feb 2022 01:53:06 +0100 (CET)","by mail-ej1-x62d.google.com with SMTP id qk11so23908242ejb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Feb 2022 16:53:06 -0800 (PST)","from e28887faee29.8.8.8.8 ([91.224.238.83])\n\tby smtp.gmail.com with ESMTPSA id\n\tgj7sm3605326ejc.90.2022.02.19.16.53.05\n\tfor <libcamera-devel@lists.libcamera.org>\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 19 Feb 2022 16:53:05 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"kKQVXPrg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:subject:date:message-id;\n\tbh=pZ/zwfYxj+ywyblg2W8gT3fPKT/I25PrX23fzbPqd4c=;\n\tb=kKQVXPrgfPjMk5y55LbSCPENTjZewscDNOEPZWrcdOf6j04ZEk7LPz3N2lqW2iqLk8\n\tvbim3AvUn9ZJI130BCE+uZZRlX1c6uimZ6OoY/VUpduI/9M0sajnszahNh+/B84i8/1t\n\tpMIXCV/ShUrctSG/c5BaLwdo7ZJ1hKe/oyPOKNddEK2PZzZrxOjdJINgSiTQrWpVm2L8\n\tVVYNCn+457u078wG+NXeMd2d6VkIkHNSaFbRcjgcF/7SrApAcy2gMym/17kFbNwoei8K\n\t4nE1VAnAI8ImdYI236E1MKnfnHAYiZpHZVnZ2RmGx2WDmAuNOBO0wmqad4gFDTWfIh2J\n\ttVww==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:subject:date:message-id;\n\tbh=pZ/zwfYxj+ywyblg2W8gT3fPKT/I25PrX23fzbPqd4c=;\n\tb=gVco2uqph3Bqv5ORfY3xqhfLu2pmgxUj9WwsGrViSQ+kpGSJLADPmIFrsDjtG+nuDQ\n\tmpzS8iPtgYL94ezJvvsobX3+PQ3YO/dOXBFuuzaYXxMyr9Kp6O80hyHuPcScOrSCEjI6\n\t+6aBi71edirTsofscD4H2aLxLXeobMoltIogldnbeeEaLBrp/taRIHrpwXVcPn22n88O\n\tXyT2poiGLOLn85gLiWdhz1WBf8b7zDCYhac9kds4kKYs6aOV/zgpAntBAJk0la5KuNAz\n\tiFwRjKKCf9Ks01V5nTnRB4B6umnk3/FmQpDazdbJB3aA+6altIyS2O/mwvfWztho2smC\n\tAviw==","X-Gm-Message-State":"AOAM530VF+BlGj8ul7XE0I5UICbfCgnKcoMN2MVBGSAZpTaMJUqTQSw4\n\tH7c7wsQjv0KvnvJZ0qzwF5lIGYI2FtiqkA==","X-Google-Smtp-Source":"ABdhPJxFg3nIbibmT+wwq1itcVvxxkQ5WItV25Fm+5kRxnxN2nh0+3kSpmDqX8MXiadrd0HLrOF/1A==","X-Received":"by 2002:a17:906:a145:b0:6ae:e45d:15b6 with SMTP id\n\tbu5-20020a170906a14500b006aee45d15b6mr11250667ejb.714.1645318386072; \n\tSat, 19 Feb 2022 16:53:06 -0800 (PST)","From":"Nejc Galof <galof.nejc@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 20 Feb 2022 01:52:57 +0100","Message-Id":"<20220220005257.30480-1-galof.nejc@gmail.com>","X-Mailer":"git-send-email 2.17.1","Subject":"[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>"},"content":"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(-)","diff":"diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\nindex 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@@ -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 \n","prefixes":["libcamera-devel"]}