Patch Detail
Show a patch.
GET /api/patches/22184/?format=api
{ "id": 22184, "url": "https://patchwork.libcamera.org/api/patches/22184/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22184/", "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": "<20241205163411.1160094-3-pobrn@protonmail.com>", "date": "2024-12-05T16:34:24", "name": "[v1,3/3] libcamera: yaml_parser: Use `YamlObject::find()` in contains/operator[]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "312fc48663180f340bd00c0e1b68a06f40fdbf13", "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/22184/mbox/", "series": [ { "id": 4852, "url": "https://patchwork.libcamera.org/api/series/4852/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4852", "date": "2024-12-05T16:34:14", "name": "[v1,1/3] libcamera: yaml_parser: Add `YamlObject::find(key)`", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4852/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22184/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22184/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 9B14DC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 5 Dec 2024 16:37:33 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4CD946610A;\n\tThu, 5 Dec 2024 17:37:33 +0100 (CET)", "from mail-40131.protonmail.ch (mail-40131.protonmail.ch\n\t[185.70.40.131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D50E06608C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 5 Dec 2024 17:37:31 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"nCvEtIcB\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1733416641; x=1733675841;\n\tbh=t1h0h9GL4LKAg+YNzPdrr7QgYlXuCZ9t8j1zqNfJIuQ=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=nCvEtIcBJDxsM0XDLgQeXaZwYcWsXQ8WqSC2ydyaIOY3xa6cttenVe488qcE78cPg\n\tHAlKxQ6DTBzyDbVxjk7FXxo+ZIgfQomu3nHc4rcyfpCXazWlziaV7UoDodTIK1Fdbv\n\ttIQwMeBna5XEzd0ExdwERtKN6YEiqdRuUGrwTITOq6q1gI2IbPGGzX4JTX0oY5vI81\n\t/0G+IZ7nFc3C1omggHa/P4NjQAKVK0M2EB1xQvk1SoENV7Y3u4gQHtEqvz2cZbCEaS\n\t9dGoxD29ttAcyko+IIvbUwMiQ3cdZU2l8TNkw/en/h2XTkjwwWWdg2Cvkgsx2AwcoO\n\tQ96MK1Es4s7vA==", "Date": "Thu, 05 Dec 2024 16:34:24 +0000", "To": "libcamera-devel@lists.libcamera.org", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Subject": "[PATCH v1 3/3] libcamera: yaml_parser: Use `YamlObject::find()` in\n\tcontains/operator[]", "Message-ID": "<20241205163411.1160094-3-pobrn@protonmail.com>", "In-Reply-To": "<20241205163411.1160094-1-pobrn@protonmail.com>", "References": "<20241205163411.1160094-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "X-Pm-Message-ID": "b0c478d199faf3ed248621d9e6788bd138a266b3", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "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": "Use `YamlObject::find()` to implement `YamlObject::{contains,operator[]}()`.\nThis way there is a single source of truth for dictionary lookups.\n\nFurthermore, inline `YamlObject::contains()` as it can trivially\nbe expressed as a call to `find()`.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n include/libcamera/internal/yaml_parser.h | 6 +++++-\n src/libcamera/yaml_parser.cpp | 14 ++------------\n 2 files changed, 7 insertions(+), 13 deletions(-)", "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 796e3e90..20dab2f3 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -207,7 +207,11 @@ public:\n \n \tconst YamlObject &operator[](std::size_t index) const;\n \n-\tbool contains(std::string_view key) const;\n+\tbool contains(std::string_view key) const\n+\t{\n+\t\treturn find(key);\n+\t}\n+\n \tconst YamlObject &operator[](std::string_view key) const;\n \tconst YamlObject *find(std::string_view key) const;\n \ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex da8cb61f..72483ef3 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -369,10 +369,6 @@ const YamlObject &YamlObject::operator[](std::size_t index) const\n *\n * \\return True if an element exists, false otherwise\n */\n-bool YamlObject::contains(std::string_view key) const\n-{\n-\treturn dictionary_.find(key) != dictionary_.end();\n-}\n \n /**\n * \\fn YamlObject::operator[](std::string_view key) const\n@@ -387,14 +383,8 @@ bool YamlObject::contains(std::string_view key) const\n */\n const YamlObject &YamlObject::operator[](std::string_view key) const\n {\n-\tif (type_ != Type::Dictionary)\n-\t\treturn empty;\n-\n-\tauto iter = dictionary_.find(key);\n-\tif (iter == dictionary_.end())\n-\t\treturn empty;\n-\n-\treturn *iter->second;\n+\tauto *child = find(key);\n+\treturn child ? *child : empty;\n }\n \n /**\n", "prefixes": [ "v1", "3/3" ] }