Show a patch.

GET /api/patches/19599/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 19599,
    "url": "https://patchwork.libcamera.org/api/patches/19599/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19599/",
    "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": "<20240301212121.9072-9-laurent.pinchart@ideasonboard.com>",
    "date": "2024-03-01T21:20:57",
    "name": "[PATCH/RFC,08/32] libcamera: v4l2_subdevice: Replace Routing::toString() with operator<<()",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "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/19599/mbox/",
    "series": [
        {
            "id": 4197,
            "url": "https://patchwork.libcamera.org/api/series/4197/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4197",
            "date": "2024-03-01T21:20:49",
            "name": "libcamera: Support the upstream Unicam driver",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4197/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19599/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19599/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 CA8AAC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  1 Mar 2024 21:21:34 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D2DF6291F;\n\tFri,  1 Mar 2024 22:21:34 +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 C984B62878\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Mar 2024 22:21:31 +0100 (CET)",
            "from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5659CD04;\n\tFri,  1 Mar 2024 22:21:17 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"EqTZfo88\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709328077;\n\tbh=uU13D15WMyE83Jjb8watRMLUDFwv/tSjVB+iSXnv2rs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=EqTZfo88GWN8gV5j9uCmNbIwP86QicQ9II25QDnJEh68ke3s+v6qb2X4P5/hQbTKe\n\tyUILF6yPsTO7w84gEeTdAFg93fOB4A2A+BN4PZ00zvBKSItkDaj8H4Lrgd5pvz4RPW\n\txPETEL/891dELHes4pihIMPJ66Bzw1if+4D+irdg=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH/RFC 08/32] libcamera: v4l2_subdevice: Replace\n\tRouting::toString() with operator<<()",
        "Date": "Fri,  1 Mar 2024 23:20:57 +0200",
        "Message-ID": "<20240301212121.9072-9-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240301212121.9072-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20240301212121.9072-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>",
        "Cc": "Sakari Ailus <sakari.ailus@iki.fi>",
        "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 5a3c6a02f57c..5dedfde4107f 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -871,30 +871,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": [
        "PATCH/RFC",
        "08/32"
    ]
}