[libcamera-devel] pipeline: raspberrypi: Make RPi::Stream::name() return const std::string &
diff mbox series

Message ID 20230427072014.26890-1-naush@raspberrypi.com
State Superseded
Headers show
Series
  • [libcamera-devel] pipeline: raspberrypi: Make RPi::Stream::name() return const std::string &
Related show

Commit Message

Naushir Patuck April 27, 2023, 7:20 a.m. UTC
Return a const std::string reference from RPi::Stream::name() to avoid
copying a string when not needed.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/pipeline/rpi/common/rpi_stream.cpp | 2 +-
 src/libcamera/pipeline/rpi/common/rpi_stream.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi April 27, 2023, 7:46 a.m. UTC | #1
Hi Naush

On Thu, Apr 27, 2023 at 08:20:14AM +0100, Naushir Patuck via libcamera-devel wrote:
> Return a const std::string reference from RPi::Stream::name() to avoid
> copying a string when not needed.
>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  src/libcamera/pipeline/rpi/common/rpi_stream.cpp | 2 +-
>  src/libcamera/pipeline/rpi/common/rpi_stream.h   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
> index 3690667e9aa6..b7e4130f5e56 100644
> --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
> +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
> @@ -19,7 +19,7 @@ V4L2VideoDevice *Stream::dev() const
>  	return dev_.get();
>  }
>
> -std::string Stream::name() const
> +const std::string &Stream::name() const
>  {
>  	return name_;
>  }
> diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h
> index 1aae674967e1..b8c74de35863 100644
> --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h
> +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h
> @@ -49,7 +49,7 @@ public:
>  	}
>
>  	V4L2VideoDevice *dev() const;
> -	std::string name() const;
> +	const std::string &name() const;
>  	bool isImporter() const;
>  	void resetBuffers();
>
> --
> 2.34.1
>
Laurent Pinchart April 27, 2023, 2:03 p.m. UTC | #2
Hi Naush,

Thank you for the patch.

On Thu, Apr 27, 2023 at 08:20:14AM +0100, Naushir Patuck via libcamera-devel wrote:
> Return a const std::string reference from RPi::Stream::name() to avoid
> copying a string when not needed.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/pipeline/rpi/common/rpi_stream.cpp | 2 +-
>  src/libcamera/pipeline/rpi/common/rpi_stream.h   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
> index 3690667e9aa6..b7e4130f5e56 100644
> --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
> +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
> @@ -19,7 +19,7 @@ V4L2VideoDevice *Stream::dev() const
>  	return dev_.get();
>  }
>  
> -std::string Stream::name() const
> +const std::string &Stream::name() const
>  {
>  	return name_;
>  }
> diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h
> index 1aae674967e1..b8c74de35863 100644
> --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h
> +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h
> @@ -49,7 +49,7 @@ public:
>  	}
>  
>  	V4L2VideoDevice *dev() const;
> -	std::string name() const;
> +	const std::string &name() const;
>  	bool isImporter() const;
>  	void resetBuffers();
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
index 3690667e9aa6..b7e4130f5e56 100644
--- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
@@ -19,7 +19,7 @@  V4L2VideoDevice *Stream::dev() const
 	return dev_.get();
 }
 
-std::string Stream::name() const
+const std::string &Stream::name() const
 {
 	return name_;
 }
diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h
index 1aae674967e1..b8c74de35863 100644
--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h
+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h
@@ -49,7 +49,7 @@  public:
 	}
 
 	V4L2VideoDevice *dev() const;
-	std::string name() const;
+	const std::string &name() const;
 	bool isImporter() const;
 	void resetBuffers();