[v2,1/3] libcamera: virtual: Avoid some copies
diff mbox series

Message ID 20241217174707.174777-1-pobrn@protonmail.com
State New
Headers show
Series
  • [v2,1/3] libcamera: virtual: Avoid some copies
Related show

Commit Message

Barnabás Pőcze Dec. 17, 2024, 5:47 p.m. UTC
There is no reason make copies, these functions return
const lvalue references, access the data through those.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/pipeline/virtual/image_frame_generator.cpp  | 2 +-
 src/libcamera/pipeline/virtual/test_pattern_generator.cpp | 2 +-
 src/libcamera/pipeline/virtual/virtual.cpp                | 3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/virtual/image_frame_generator.cpp b/src/libcamera/pipeline/virtual/image_frame_generator.cpp
index 277efbb09..d1545b5d9 100644
--- a/src/libcamera/pipeline/virtual/image_frame_generator.cpp
+++ b/src/libcamera/pipeline/virtual/image_frame_generator.cpp
@@ -129,7 +129,7 @@  int ImageFrameGenerator::generateFrame(const Size &size, const FrameBuffer *buff
 
 	MappedFrameBuffer mappedFrameBuffer(buffer, MappedFrameBuffer::MapFlag::Write);
 
-	auto planes = mappedFrameBuffer.planes();
+	const auto &planes = mappedFrameBuffer.planes();
 
 	/* Loop only around the number of images available */
 	frameIndex_ %= imageFrameDatas_.size();
diff --git a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp
index 7bc2b338c..47d341919 100644
--- a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp
+++ b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp
@@ -25,7 +25,7 @@  int TestPatternGenerator::generateFrame(const Size &size,
 	MappedFrameBuffer mappedFrameBuffer(buffer,
 					    MappedFrameBuffer::MapFlag::Write);
 
-	auto planes = mappedFrameBuffer.planes();
+	const auto &planes = mappedFrameBuffer.planes();
 
 	shiftLeft(size);
 
diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp
index a44f286b7..ce0c38813 100644
--- a/src/libcamera/pipeline/virtual/virtual.cpp
+++ b/src/libcamera/pipeline/virtual/virtual.cpp
@@ -274,8 +274,7 @@  int PipelineHandlerVirtual::exportFrameBuffers([[maybe_unused]] Camera *camera,
 		return -ENOBUFS;
 
 	const StreamConfiguration &config = stream->configuration();
-
-	auto info = PixelFormatInfo::info(config.pixelFormat);
+	const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);
 
 	std::vector<unsigned int> planeSizes;
 	for (size_t i = 0; i < info.planes.size(); ++i)