From patchwork Thu May 26 13:30:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16064 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 BB3BABD160 for ; Thu, 26 May 2022 13:31:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 780DC611C0; Thu, 26 May 2022 15:31:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653571863; bh=3mRS+cQGJB7tb/A1GfWTWfgbA6TA0PeLvmQgN4P5+vk=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XzrykqD4Uunb2WdXDg84g1c8Wb6ebRL+biNsg/lNlYyAW/YANypp2VKjMGlFxqkZA HQTF7D9G0m5byw3fe9ZBYY8SIC/4WgRswC8adwH46PZ/Yv643YFKWBhhsuZtA8Abe/ 5mgnf9fMmUmcPMHX3BOld8SjWqJkLlnZ0RVzToLuBQ5+XO9mWvfOUXuPb3Byj4PwJe t80M9/dZXYL3upDVoKG8uUCaEgrgpSX2RiYuAQx/sEskuMR8bRaUAoBhToxzm3inIo oMuCl27A1j8VnEevWk9Sq1pRX/hhH0KRgx7GoH6rJLCjH9IkC0dycMA7eah6+uXMN1 j1v3ZLdr+BcdQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B3DE860DB0 for ; Thu, 26 May 2022 15:31:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Tj8WCz7j"; dkim-atps=neutral Received: from pendragon.lan (unknown [37.120.212.14]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E8C46D4 for ; Thu, 26 May 2022 15:31:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653571861; bh=3mRS+cQGJB7tb/A1GfWTWfgbA6TA0PeLvmQgN4P5+vk=; h=From:To:Subject:Date:From; b=Tj8WCz7jAD0EdhxjSQcWx+sDqszjFe6IAO8yDvp/FuLJInXqi8msvWp8lhtsbPO4/ 6n6GMDpVWGkudYAynPCnEhP4uyIksR11oaQExInKEkVlMk+4/6Q0+ymvu6g0iWeK7V hfuF1aqeygdk/aLqdIf9g+LoJEuom3T4nsX4oOcc= To: libcamera-devel@lists.libcamera.org Date: Thu, 26 May 2022 16:30:52 +0300 Message-Id: <20220526133052.18791-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: media_device: Return string references to avoid copies 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The MediaDevice::driver(), deviceNode() and model() functions return a const std::string, copying the string stored internally in the class. Return references instead to avoid copies. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- include/libcamera/internal/media_device.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) base-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h index 6e2a63f38229..eb8cfde48e20 100644 --- a/include/libcamera/internal/media_device.h +++ b/include/libcamera/internal/media_device.h @@ -38,9 +38,9 @@ public: int populate(); bool isValid() const { return valid_; } - const std::string driver() const { return driver_; } - const std::string deviceNode() const { return deviceNode_; } - const std::string model() const { return model_; } + const std::string &driver() const { return driver_; } + const std::string &deviceNode() const { return deviceNode_; } + const std::string &model() const { return model_; } unsigned int version() const { return version_; } unsigned int hwRevision() const { return hwRevision_; }