[libcamera-devel] [PATCH] libcamera: media_device: Return string references to avoid copies
Kieran Bingham
kieran.bingham at ideasonboard.com
Thu May 26 16:02:03 CEST 2022
Quoting Laurent Pinchart via libcamera-devel (2022-05-26 14:30:52)
> 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.
>
Seems quite reasonable.
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart 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
> --
> Regards,
>
> Laurent Pinchart
>
More information about the libcamera-devel
mailing list