Patch Detail
Show a patch.
GET /api/patches/19727/?format=api
{ "id": 19727, "url": "https://patchwork.libcamera.org/api/patches/19727/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19727/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240315001613.2033-9-laurent.pinchart@ideasonboard.com>", "date": "2024-03-15T00:16:07", "name": "[v2,08/14] libcamera: v4l2_subdevice: Replace Routing::toString() with operator<<()", "commit_ref": "e8f01b37e809bd7b101e6528b59c314ea3268068", "pull_url": null, "state": "accepted", "archived": false, "hash": "d178f71108ee8a685ba681692d61825b5656020b", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19727/mbox/", "series": [ { "id": 4226, "url": "https://patchwork.libcamera.org/api/series/4226/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4226", "date": "2024-03-15T00:15:59", "name": "libcamera: Prepare for new camera sensor class", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4226/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19727/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19727/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 6610DBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Mar 2024 00:16:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F30FF62CAF;\n\tFri, 15 Mar 2024 01:16:37 +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 C86AB62CA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Mar 2024 01:16:27 +0100 (CET)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 051C0A9A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Mar 2024 01:16:03 +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=\"SEtkEtYG\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710461764;\n\tbh=CkwfBp+j3AvDekhK2aokSGskC6v0a7ndLCQggLj7LiQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=SEtkEtYGay2GSMNaxXc6j6cMwmH7sJj8SmOUSHvBRmjkO0P7kqbbAEGAHeRVcnVI+\n\ttcswEga+tyg08Mu6SqfuUb5ofmzlpTflI3vC2F43thpjBWh7FTrO2jDWcvm2xe3xe8\n\toffrnaL1tGd2Tahbb4XyKQHH92BtHrosUX1glA8s=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v2 08/14] libcamera: v4l2_subdevice: Replace\n\tRouting::toString() with operator<<()", "Date": "Fri, 15 Mar 2024 02:16:07 +0200", "Message-ID": "<20240315001613.2033-9-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.2", "In-Reply-To": "<20240315001613.2033-1-laurent.pinchart@ideasonboard.com>", "References": "<20240315001613.2033-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "The main (and only at the moment) use case for the Routing::toString()\nfunction is to print a representation of the routing table in a log\nmessage. The function is implemented using an std::stringstream, and the\nreturned std::string is then inserted into an std::ostream. This is\ninefficient. Replace the function with a specialization of the\noperator<<() and use it in the caller.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_subdevice.h | 7 ++---\n src/libcamera/pipeline/simple/simple.cpp | 2 +-\n src/libcamera/v4l2_subdevice.cpp | 29 +++++++++++----------\n 3 files changed, 18 insertions(+), 20 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 6cd36730371a..2939dc2411c6 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -95,11 +95,7 @@ public:\n \t\tunsigned int stream;\n \t};\n \n-\tclass Routing : public std::vector<struct v4l2_subdev_route>\n-\t{\n-\tpublic:\n-\t\tstd::string toString() const;\n-\t};\n+\tusing Routing = std::vector<struct v4l2_subdev_route>;\n \n \texplicit V4L2Subdevice(const MediaEntity *entity);\n \t~V4L2Subdevice();\n@@ -178,5 +174,6 @@ static inline bool operator!=(const V4L2Subdevice::Stream &lhs,\n }\n \n std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream);\n+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Routing &routing);\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 3d0424969a89..feea26fd124f 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -1388,7 +1388,7 @@ int SimplePipelineHandler::resetRoutingTable(V4L2Subdevice *subdev)\n \n \tLOG(SimplePipeline, Debug)\n \t\t<< \"Routing table of \" << subdev->deviceNode()\n-\t\t<< \" reset to \" << routing.toString();\n+\t\t<< \" reset to \" << routing;\n \n \treturn 0;\n }\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex cc079425bb16..deef681e0d3a 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -899,30 +899,31 @@ std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream)\n }\n \n /**\n- * \\class V4L2Subdevice::Routing\n+ * \\typedef V4L2Subdevice::Routing\n * \\brief V4L2 subdevice routing table\n *\n * This class stores a subdevice routing table as a vector of routes.\n */\n \n /**\n- * \\brief Assemble and return a string describing the routing table\n- * \\return A string describing the routing table\n+ * \\brief Insert a text representation of a V4L2Subdevice::Routing into an\n+ *\toutput stream\n+ * \\param[in] out The output stream\n+ * \\param[in] routing The V4L2Subdevice::Routing\n+ * \\return The output stream \\a out\n */\n-std::string V4L2Subdevice::Routing::toString() const\n+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Routing &routing)\n {\n-\tstd::stringstream routing;\n-\n-\tfor (const auto &[i, route] : utils::enumerate(*this)) {\n-\t\trouting << \"[\" << i << \"] \"\n-\t\t\t<< route.sink_pad << \"/\" << route.sink_stream << \" -> \"\n-\t\t\t<< route.source_pad << \"/\" << route.source_stream\n-\t\t\t<< \" (\" << utils::hex(route.flags) << \")\";\n-\t\tif (i != size() - 1)\n-\t\t\trouting << \", \";\n+\tfor (const auto &[i, route] : utils::enumerate(routing)) {\n+\t\tout << \"[\" << i << \"] \"\n+\t\t << route.sink_pad << \"/\" << route.sink_stream << \" -> \"\n+\t\t << route.source_pad << \"/\" << route.source_stream\n+\t\t << \" (\" << utils::hex(route.flags) << \")\";\n+\t\tif (i != routing.size() - 1)\n+\t\t\tout << \", \";\n \t}\n \n-\treturn routing.str();\n+\treturn out;\n }\n \n /**\n", "prefixes": [ "v2", "08/14" ] }