{"id":3242,"url":"https://patchwork.libcamera.org/api/1.1/patches/3242/?format=json","web_url":"https://patchwork.libcamera.org/patch/3242/","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":"<20200323103938.11026-1-laurent.pinchart@ideasonboard.com>","date":"2020-03-23T10:39:38","name":"[libcamera-devel] qcam: main: Cache lookup of role property","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"db3f908b0bac01cc05afece3fc034dacd223a51c","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/1.1/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/3242/mbox/","series":[{"id":759,"url":"https://patchwork.libcamera.org/api/1.1/series/759/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=759","date":"2020-03-23T10:39:38","name":"[libcamera-devel] qcam: main: Cache lookup of role property","version":1,"mbox":"https://patchwork.libcamera.org/series/759/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3242/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3242/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02D6160412\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 11:39:51 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 748F3308\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 11:39:51 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584959991;\n\tbh=TYp/uvjUYfJj0y8WC83o79hIFy1y0tuZugUwaa0e64I=;\n\th=From:To:Subject:Date:From;\n\tb=jYuYdq68p42tPjZQoRVtq0YqY2yKUgQliGxSzONhRxm/EL9lX2UXrk3tCzVOWLlMW\n\ted+hLuKN9KktHKwWv7TnAcuShAcKaUYc1jT1NHewmMLWJC/maeMtfeCCcY2zFAgJMf\n\t9a8KiyQ9P4TwwieNgdL/nDf6VBDwk2stRAO0tY6w=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 23 Mar 2020 12:39:38 +0200","Message-Id":"<20200323103938.11026-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] qcam: main: Cache lookup of role property","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>","X-List-Received-Date":"Mon, 23 Mar 2020 10:39:52 -0000"},"content":"The code handling the stream role option retrieves the role property and\nconverts it to a string in every branch. Cache it and use the cached\nvalue.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/main.cpp | 16 ++++++++++------\n 1 file changed, 10 insertions(+), 6 deletions(-)","diff":"diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 2a0a830ff371..56059ab6c047 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -209,17 +209,21 @@ int CamApp::prepareConfig()\n \t\tfor (auto const &value : streamOptions) {\n \t\t\tKeyValueParser::Options opt = value.toKeyValues();\n \n-\t\t\tif (!opt.isSet(\"role\")) {\n-\t\t\t\troles.push_back(StreamRole::VideoRecording);\n-\t\t\t} else if (opt[\"role\"].toString() == \"viewfinder\") {\n+\t\t\tstd::string role;\n+\t\t\tif (opt.isSet(\"role\"))\n+\t\t\t\trole = opt[\"role\"].toString();\n+\t\t\telse\n+\t\t\t\trole = \"viewfinder\";\n+\n+\t\t\tif (role == \"viewfinder\") {\n \t\t\t\troles.push_back(StreamRole::Viewfinder);\n-\t\t\t} else if (opt[\"role\"].toString() == \"video\") {\n+\t\t\t} else if (role == \"video\") {\n \t\t\t\troles.push_back(StreamRole::VideoRecording);\n-\t\t\t} else if (opt[\"role\"].toString() == \"still\") {\n+\t\t\t} else if (role == \"still\") {\n \t\t\t\troles.push_back(StreamRole::StillCapture);\n \t\t\t} else {\n \t\t\t\tstd::cerr << \"Unknown stream role \"\n-\t\t\t\t\t  << opt[\"role\"].toString() << std::endl;\n+\t\t\t\t\t  << role << std::endl;\n \t\t\t\treturn -EINVAL;\n \t\t\t}\n \t\t}\n","prefixes":["libcamera-devel"]}