Show a patch.

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

{
    "id": 22325,
    "url": "https://patchwork.libcamera.org/api/patches/22325/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22325/",
    "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": "<20241215230206.11002-6-laurent.pinchart@ideasonboard.com>",
    "date": "2024-12-15T23:02:03",
    "name": "[RFC,5/8] libcamera: base: utils: Use std::string_view",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7605e824314028d1b8242da8e2e2b3e6f1eee3a0",
    "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/22325/mbox/",
    "series": [
        {
            "id": 4889,
            "url": "https://patchwork.libcamera.org/api/series/4889/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4889",
            "date": "2024-12-15T23:01:58",
            "name": "libcamera: Use std::string_view",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4889/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22325/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22325/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 753B1C32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 15 Dec 2024 23:02:38 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E621D67F45;\n\tMon, 16 Dec 2024 00:02:37 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84F9967F1D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Dec 2024 00:02:29 +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 5025B2C6;\n\tMon, 16 Dec 2024 00:01:53 +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=\"OY6LTa9b\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734303713;\n\tbh=jicbLubGAelOBp5iooZvoFoBWq8tpZBmR9fVz8vVW0Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OY6LTa9bGZ+zBaw3oEZNEXATBsFb+pXH1n+RW8EwCDP+mztEp1m4+59EXI6iz4Paa\n\tpgxVOefYaQ6DgFVQTYvUbYf25NPz1CRQbwWOvQeOEiJQcGu095CI0VZ2i10KNJ4T3/\n\tCKbu0kXW+ch0hnU3lKDxLySiBkR1pvS0GH3MAM4s=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "Subject": "[RFC PATCH 5/8] libcamera: base: utils: Use std::string_view",
        "Date": "Mon, 16 Dec 2024 01:02:03 +0200",
        "Message-ID": "<20241215230206.11002-6-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.45.2",
        "In-Reply-To": "<20241215230206.11002-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20241215230206.11002-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": "Replace usage of const std::string references passed to class member\nfunctions with std::string_view. This allows using static C string\nliterals in the callers without the overhead of constructing a\nstd::string instance.\n\nAs std::string can't be implicitly constructed from std::string_view, an\nexplicit construction is added at the end of dirname().\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/utils.h | 15 ++++++++-------\n src/libcamera/base/utils.cpp   | 14 +++++++-------\n 2 files changed, 15 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h\nindex dd012fd58501cd8d..3ef1c0e87383f8d2 100644\n--- a/include/libcamera/base/utils.h\n+++ b/include/libcamera/base/utils.h\n@@ -15,6 +15,7 @@\n #include <sstream>\n #include <string.h>\n #include <string>\n+#include <string_view>\n #include <sys/time.h>\n #include <type_traits>\n #include <utility>\n@@ -38,7 +39,7 @@ namespace utils {\n const char *basename(const char *path);\n \n char *secure_getenv(const char *name);\n-std::string dirname(const std::string &path);\n+std::string dirname(std::string_view path);\n \n template<typename T>\n std::vector<typename T::key_type> map_keys(const T &map)\n@@ -143,7 +144,7 @@ size_t strlcpy(char *dst, const char *src, size_t size);\n \n #ifndef __DOXYGEN__\n template<typename Container, typename UnaryOp>\n-std::string join(const Container &items, const std::string &sep, UnaryOp op)\n+std::string join(const Container &items, std::string_view sep, UnaryOp op)\n {\n \tstd::ostringstream ss;\n \tbool first = true;\n@@ -162,7 +163,7 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op)\n }\n \n template<typename Container>\n-std::string join(const Container &items, const std::string &sep)\n+std::string join(const Container &items, std::string_view sep)\n {\n \tstd::ostringstream ss;\n \tbool first = true;\n@@ -181,7 +182,7 @@ std::string join(const Container &items, const std::string &sep)\n }\n #else\n template<typename Container, typename UnaryOp>\n-std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr);\n+std::string join(const Container &items, std::string_view sep, UnaryOp op = nullptr);\n #endif\n \n namespace details {\n@@ -189,7 +190,7 @@ namespace details {\n class StringSplitter\n {\n public:\n-\tStringSplitter(const std::string &str, const std::string &delim);\n+\tStringSplitter(std::string_view str, std::string_view delim);\n \n \tclass iterator\n \t{\n@@ -238,9 +239,9 @@ private:\n \n } /* namespace details */\n \n-details::StringSplitter split(const std::string &str, const std::string &delim);\n+details::StringSplitter split(std::string_view str, std::string_view delim);\n \n-std::string toAscii(const std::string &str);\n+std::string toAscii(std::string_view str);\n \n std::string libcameraBuildPath();\n std::string libcameraSourcePath();\ndiff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp\nindex bcfc1941a92a3d69..886aa9ecdc2bddfe 100644\n--- a/src/libcamera/base/utils.cpp\n+++ b/src/libcamera/base/utils.cpp\n@@ -80,7 +80,7 @@ char *secure_getenv(const char *name)\n  *\n  * \\return A string of the directory component of the path\n  */\n-std::string dirname(const std::string &path)\n+std::string dirname(std::string_view path)\n {\n \tif (path.empty())\n \t\treturn \".\";\n@@ -116,7 +116,7 @@ std::string dirname(const std::string &path)\n \t\tpos--;\n \t}\n \n-\treturn path.substr(0, pos + 1);\n+\treturn std::string(path.substr(0, pos + 1));\n }\n \n /**\n@@ -247,7 +247,7 @@ size_t strlcpy(char *dst, const char *src, size_t size)\n \treturn strlen(src);\n }\n \n-details::StringSplitter::StringSplitter(const std::string &str, const std::string &delim)\n+details::StringSplitter::StringSplitter(std::string_view str, std::string_view delim)\n \t: str_(str), delim_(delim)\n {\n }\n@@ -278,7 +278,7 @@ std::string details::StringSplitter::iterator::operator*() const\n \n /**\n  * \\fn template<typename Container, typename UnaryOp> \\\n- * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)\n+ * std::string utils::join(const Container &items, std::string_view sep, UnaryOp op)\n  * \\brief Join elements of a container in a string with a separator\n  * \\param[in] items The container\n  * \\param[in] sep The separator to add between elements\n@@ -293,7 +293,7 @@ std::string details::StringSplitter::iterator::operator*() const\n  */\n \n /**\n- * \\fn split(const std::string &str, const std::string &delim)\n+ * \\fn split(std::string_view str, std::string_view delim)\n  * \\brief Split a string based on a delimiter\n  * \\param[in] str The string to split\n  * \\param[in] delim The delimiter string\n@@ -305,7 +305,7 @@ std::string details::StringSplitter::iterator::operator*() const\n  * \\return An object that can be used in a range-based for loop to iterate over\n  * the substrings\n  */\n-details::StringSplitter split(const std::string &str, const std::string &delim)\n+details::StringSplitter split(std::string_view str, std::string_view delim)\n {\n \t/** \\todo Try to avoid copies of str and delim */\n \treturn details::StringSplitter(str, delim);\n@@ -319,7 +319,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n  *\n  * \\return A string equal to \\a str stripped out of all non-ASCII characters\n  */\n-std::string toAscii(const std::string &str)\n+std::string toAscii(std::string_view str)\n {\n \tstd::string ret;\n \tfor (const char &c : str)\n",
    "prefixes": [
        "RFC",
        "5/8"
    ]
}