[libcamera-devel] [PATCH] libcamera: media_device: Return string references to avoid copies

paul.elder at ideasonboard.com paul.elder at ideasonboard.com
Fri May 27 04:43:07 CEST 2022


Hi Laurent,

On Thu, May 26, 2022 at 04:30:52PM +0300, Laurent Pinchart via libcamera-devel wrote:
> 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 <laurent.pinchart at ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>

> ---
>  include/libcamera/internal/media_device.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> 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_; }
>  
> 
> base-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac


More information about the libcamera-devel mailing list