Show a patch.

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

{
    "id": 19559,
    "url": "https://patchwork.libcamera.org/api/patches/19559/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19559/",
    "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": "<20240227140953.26093-9-laurent.pinchart@ideasonboard.com>",
    "date": "2024-02-27T14:09:52",
    "name": "[8/9] libcamera: v4l2_subdevice: Replace Routing::toString() with operator<<()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "14acdfe5f0d3727b7cfe903a64216fb061603b3f",
    "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/19559/mbox/",
    "series": [
        {
            "id": 4189,
            "url": "https://patchwork.libcamera.org/api/series/4189/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4189",
            "date": "2024-02-27T14:09:44",
            "name": "libcamera: v4l2_subdevice: Prepare for embedded data support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4189/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19559/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19559/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 96C91C32C3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Feb 2024 14:10:06 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D7D662B3D;\n\tTue, 27 Feb 2024 15:10:06 +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 8C4CC62865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Feb 2024 15:10:02 +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 5C5889CE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Feb 2024 15:09:50 +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=\"i+2KtPzy\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709042990;\n\tbh=PlljiVKl7LAGV4BZoVXRQo4Tse+izRsQ2xcGG1X7+c8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=i+2KtPzy7z4cRXHHtVfS6CGwfVlvOEqt4lehUPUUaK45G/wYfhBYdhga2wml3Tp/S\n\tdx2hyabhqbOdUiwIC87VFN47doCt09s8sBsJxe9+++L8UxAPwMnY6N2+h7ZAaSyLas\n\tj3lWVEvDJKT4mOMzG4efKN3L3+b1NVnlKpBUwtEw=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH 8/9] libcamera: v4l2_subdevice: Replace Routing::toString()\n\twith operator<<()",
        "Date": "Tue, 27 Feb 2024 16:09:52 +0200",
        "Message-ID": "<20240227140953.26093-9-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240227140953.26093-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20240227140953.26093-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>\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 65003394a984..2f64b3deadfe 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -85,11 +85,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@@ -161,5 +157,6 @@ private:\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 1145e80847ba..1dbbd7fe91d6 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -1387,7 +1387,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 efe8b0f793e9..1670c31a9656 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -844,30 +844,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": [
        "8/9"
    ]
}