Patch Detail
Show a patch.
GET /api/patches/24449/?format=api
{ "id": 24449, "url": "https://patchwork.libcamera.org/api/patches/24449/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24449/", "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": "<20250924124713.3361707-4-barnabas.pocze@ideasonboard.com>", "date": "2025-09-24T12:47:08", "name": "[RFC,v1,3/7] libcamera: controls: Add rvalue `ControlList::merge()`", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "fdc4fc4542a57894cd48b2bd520e8f208f276f00", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24449/mbox/", "series": [ { "id": 5457, "url": "https://patchwork.libcamera.org/api/series/5457/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5457", "date": "2025-09-24T12:47:05", "name": "libcamera: camera: Add `applyControls()`", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5457/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24449/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24449/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 959F2C3331\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Sep 2025 12:47:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8E2106B5FE;\n\tWed, 24 Sep 2025 14:47:28 +0200 (CEST)", "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 41DF26B5F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Sep 2025 14:47:17 +0200 (CEST)", "from pb-laptop.local (185.221.140.70.nat.pool.zt.hu\n\t[185.221.140.70])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 513431E30;\n\tWed, 24 Sep 2025 14:45:53 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"GmIc45Y+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758717953;\n\tbh=PULD/bhzlEF1pA8U1Nm12ABhT2Gudiv9VA4pjEP6cP8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=GmIc45Y+F7EGcYqzwG03YsfbmUNQJNtjjlWd3mfwCvqQY8T69PUykrHr14oeiRsue\n\tsBJ2KxyMx3wMWAcQwvbO+97T5/8bmgagDsfJAgSSsnXEtteKWOmdGqD1av36eq4F5j\n\tdm2PmCXpKZpolgHaa5UVtJgwcn2OL0yc3mUeZhcI=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[RFC PATCH v1 3/7] libcamera: controls: Add rvalue\n\t`ControlList::merge()`", "Date": "Wed, 24 Sep 2025 14:47:08 +0200", "Message-ID": "<20250924124713.3361707-4-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20250924124713.3361707-1-barnabas.pocze@ideasonboard.com>", "References": "<20250924124713.3361707-1-barnabas.pocze@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "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": "Add an overload of `ControlList::merge()` that takes the source `ControlList`\nobject via an rvalue. In contrast to the other overload, this one does not\nmake copies, it uses `std::unordered_map::merge()` to move key-value pairs\nfrom one map to the other.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/controls.h | 1 +\n src/libcamera/controls.cpp | 42 +++++++++++++++++++++++++++++++++---\n 2 files changed, 40 insertions(+), 3 deletions(-)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 32fb31f78..5d4a53c46 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -432,6 +432,7 @@ public:\n \n \tvoid clear() { controls_.clear(); }\n \tvoid merge(const ControlList &source, MergePolicy policy = MergePolicy::KeepExisting);\n+\tvoid merge(ControlList &&source, MergePolicy policy = MergePolicy::KeepExisting);\n \n \tbool contains(unsigned int id) const;\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 1e1b49e6b..54cd3b703 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -1005,9 +1005,6 @@ ControlList::ControlList(const ControlInfoMap &infoMap,\n *\n * Only control lists created from the same ControlIdMap or ControlInfoMap may\n * be merged. Attempting to do otherwise results in undefined behaviour.\n- *\n- * \\todo Reimplement or implement an overloaded version which internally uses\n- * std::unordered_map::merge() and accepts a non-const argument.\n */\n void ControlList::merge(const ControlList &source, MergePolicy policy)\n {\n@@ -1035,6 +1032,45 @@ void ControlList::merge(const ControlList &source, MergePolicy policy)\n \t}\n }\n \n+/**\n+ * \\brief Merge the \\a source into the ControlList\n+ * \\param[in] source The ControlList to merge into this object\n+ * \\param[in] policy Controls if existing elements in *this shall be\n+ * overwritten\n+ *\n+ * Merging two control lists moves elements from the \\a source and inserts\n+ * them in *this. If the \\a source contains elements whose key is already\n+ * present in *this, then those elements are only overwritten if\n+ * \\a policy is MergePolicy::OverwriteExisting.\n+ *\n+ * Only control lists created from the same ControlIdMap or ControlInfoMap may\n+ * be merged. Attempting to do otherwise results in undefined behaviour.\n+ */\n+void ControlList::merge(ControlList &&source, MergePolicy policy)\n+{\n+\t/**\n+\t * \\todo ASSERT that the current and source ControlList are derived\n+\t * from a compatible ControlIdMap, to prevent undefined behaviour due to\n+\t * id collisions.\n+\t *\n+\t * This can not currently be a direct pointer comparison due to the\n+\t * duplication of the ControlIdMaps in the isolated IPA use cases.\n+\t * Furthermore, manually checking each entry of the id map is identical\n+\t * is expensive.\n+\t * See https://bugs.libcamera.org/show_bug.cgi?id=31 for further details\n+\t */\n+\n+\tswitch (policy) {\n+\tcase MergePolicy::KeepExisting:\n+\t\tcontrols_.merge(source.controls_);\n+\t\tbreak;\n+\tcase MergePolicy::OverwriteExisting:\n+\t\tsource.controls_.merge(controls_);\n+\t\tcontrols_.swap(source.controls_);\n+\t\tbreak;\n+\t}\n+}\n+\n /**\n * \\brief Check if the list contains a control with the specified \\a id\n * \\param[in] id The control numerical ID\n", "prefixes": [ "RFC", "v1", "3/7" ] }