From patchwork Fri Aug 15 11:33:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24136 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AC612BEFBE for ; Fri, 15 Aug 2025 11:34:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DD5A16926D; Fri, 15 Aug 2025 13:34:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LiFqUjbW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1165269264 for ; Fri, 15 Aug 2025 13:34:30 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id EE8B76A8; Fri, 15 Aug 2025 13:33:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257615; bh=PqXjuEd/eETxliLeoxxBIFcSSeAUo4EyKWgToqjiTes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LiFqUjbWT5k6FCvcXZe3sS4pax4F6nad0+pq4aNChAB2XCjM8LHogGSUgzgTM4cz7 qy7uRoLpbhlIZhBa96yeJbfvF2W1J/C7owatQ0OwtYVkX44G4rLp6rURcHvyzbXPvs QtBonsfqLnyIjohqSUDlIU8l1KS8F5UwfD0/a1Tg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 6/8] utils: codegen: ipc: Optimize constructors of IPA interface structures Date: Fri, 15 Aug 2025 14:33:58 +0300 Message-ID: <20250815113400.20623-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" IPA interface structures store copies of data. For members that are not PODs, such as vectors or strings, the constructors take const references to a container class storing the data, and copies it internally. This is inefficient if the caller constructs the container for the sole purpose of passing it to the IPA interface structure constructor, as it forces a copy of the data. Replace the const reference argument with a plain instance, and move it in the constructor. This allows getting rid of the data copy if the caller uses std::move(). Signed-off-by: Laurent Pinchart --- .../generators/libcamera_templates/definition_functions.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl index 8b8509f3ded6..31c70e152d4f 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl @@ -36,12 +36,12 @@ public: {{struct.mojom_name}}( {%- for field in struct.fields -%} -{{"const " if not field|is_pod}}{{field|name}} {{"&" if not field|is_pod}}_{{field.mojom_name}}{{", " if not loop.last}} +{{field|name}} _{{field.mojom_name}}{{", " if not loop.last}} {%- endfor -%} ) : {%- for field in struct.fields -%} -{{" " if loop.first}}{{field.mojom_name}}(_{{field.mojom_name}}){{", " if not loop.last}} +{{" " if loop.first}}{{field.mojom_name}}({{"std::move(" if not field|is_pod}}_{{field.mojom_name}}{{")" if not field|is_pod}}){{", " if not loop.last}} {%- endfor %} { }