Patch Detail
Show a patch.
GET /api/patches/18538/?format=api
{ "id": 18538, "url": "https://patchwork.libcamera.org/api/patches/18538/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18538/", "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": "<20230418162603.449433-1-pobrn@protonmail.com>", "date": "2023-04-18T16:26:04", "name": "[libcamera-devel,v2] libcamera: device_enumerator_udev: Use std::string_view", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "17125f5c09ab2c908711b64d8c1398565b3ecb17", "submitter": { "id": 133, "url": "https://patchwork.libcamera.org/api/people/133/?format=api", "name": "Pőcze Barnabás", "email": "pobrn@protonmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18538/mbox/", "series": [ { "id": 3843, "url": "https://patchwork.libcamera.org/api/series/3843/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3843", "date": "2023-04-18T16:26:04", "name": "[libcamera-devel,v2] libcamera: device_enumerator_udev: Use std::string_view", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3843/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18538/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18538/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 B5404BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Apr 2023 16:26:22 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DFF5627B8;\n\tTue, 18 Apr 2023 18:26:22 +0200 (CEST)", "from mail-4316.protonmail.ch (mail-4316.protonmail.ch\n\t[185.70.43.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 16DA7603A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Apr 2023 18:26:20 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681835182;\n\tbh=DAsR0m+SB229Fq2OEKmIOPcHdo/ishfT1b+qAfBNldQ=;\n\th=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=g4jf+XjjWzuCrIUGEP3al++0GDgYTf2qzgC/23yOwT2NVb886WIHwf0DqGmIMgHOS\n\tJLmZzbXIRhcm7xGFZRhGBCREWwIAnCEnQtrAEhlL43ikmq4HpdIC55z1ymoyHgtscV\n\tzkEteisldLmrmYKTyMHQ5mICiQA/elyOZ6V9F0piVDOZjSdsK3MJvhN0yxWO279m0O\n\tmNEniZq08sdP8jLvk7LV8LE4DX/dGXYx2lzQQ+RCRxS2LxWis+Tt/w/ODqNyZ3T+9T\n\tBSoSlYzON7DfqMBNAQfQqlMTcdqbvj1SSSRUG14dTUiaEn5KwXY+gt4FKTJacH2v85\n\tA4e70p4VhxGKQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1681835179; x=1682094379;\n\tbh=DAsR0m+SB229Fq2OEKmIOPcHdo/ishfT1b+qAfBNldQ=;\n\th=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date:\n\tSubject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector;\n\tb=G4X23FUsxFYiVoJoP+tpCzDYSio/tXghEk+joKMvDbEyWaYLY1gIwBt4cyBuU+2Ne\n\tkVgSwUSlxsEH40+TdMDNLBD96w68g3LwY2skFgy7HKd4gCve3+6+HpSw9+e27hdc39\n\tLSsJoygLEbRa9+6CJP5vEfKxpIoodBDZQuo75TqHDUlizshaHDicFkJiDUw2BG8/Vc\n\t5K550XWXfO9txMaUg6NSnT/UJozjziNo7/+OHEQkUNyKA6yeBAHXkSzTO7nnKNARV5\n\t1sE8tMk4VBn7xAZ8p6j34uybEsNQ7WdLil2mbJAm3ITxwG0nkwkr3uuoSLsB40fsOc\n\t9IV7TdtJeOEOg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=protonmail.com\n\theader.i=@protonmail.com\n\theader.b=\"G4X23FUs\"; dkim-atps=neutral", "Date": "Tue, 18 Apr 2023 16:26:04 +0000", "To": "libcamera-devel@lists.libcamera.org", "Message-ID": "<20230418162603.449433-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "Subject": "[libcamera-devel] [PATCH v2] libcamera: device_enumerator_udev: Use\n\tstd::string_view", "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>", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze_via_libcamera-devel?=\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "In `udevNotify()`, constructing an std::string from the device's\nassociated action is unnecessary as it is only compared against\nstatic strings, and for that purpose an std::string_view works\njust as well, while being cheaper to construct.\n\nIn the same vein, an std::string_view can be used to\nstore the device's devnode initially, and the string\nconstruction can be deferred until it is needed.\n\nFurthermore, previously `udev_device_get_devnode()` was\ncalled twice. The extra call is now removed.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/libcamera/device_enumerator_udev.cpp | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\n--\n2.40.0", "diff": "diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\nindex a63cd360..0abc1248 100644\n--- a/src/libcamera/device_enumerator_udev.cpp\n+++ b/src/libcamera/device_enumerator_udev.cpp\n@@ -13,6 +13,7 @@\n #include <list>\n #include <map>\n #include <string.h>\n+#include <string_view>\n #include <sys/ioctl.h>\n #include <sys/sysmacros.h>\n #include <unistd.h>\n@@ -331,18 +332,18 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n void DeviceEnumeratorUdev::udevNotify()\n {\n \tstruct udev_device *dev = udev_monitor_receive_device(monitor_);\n-\tstd::string action(udev_device_get_action(dev));\n-\tstd::string deviceNode(udev_device_get_devnode(dev));\n+\tstd::string_view action(udev_device_get_action(dev));\n+\tstd::string_view deviceNode(udev_device_get_devnode(dev));\n\n \tLOG(DeviceEnumerator, Debug)\n-\t\t<< action << \" device \" << udev_device_get_devnode(dev);\n+\t\t<< action << \" device \" << deviceNode;\n\n \tif (action == \"add\") {\n \t\taddUdevDevice(dev);\n \t} else if (action == \"remove\") {\n \t\tconst char *subsystem = udev_device_get_subsystem(dev);\n \t\tif (subsystem && !strcmp(subsystem, \"media\"))\n-\t\t\tremoveDevice(deviceNode);\n+\t\t\tremoveDevice(std::string(deviceNode));\n \t}\n\n \tudev_device_unref(dev);\n", "prefixes": [ "libcamera-devel", "v2" ] }