[PATCH v1] libcamera: media_object: Fix unnecessary copy

Dan Scally dan.scally at ideasonboard.com
Mon Mar 3 16:29:26 CET 2025


Hi Barnabas

On 03/03/2025 15:26, Barnabás Pőcze wrote:
> `MediaEntity::ancillaryEntities()` can just return a const lvalue
> reference to the underlying array, a copy need not be made. That
> was likely the original intention.


I think I probably just didn't know what I was doing at the time actually!

> Fixes: 9490c664b57a6c ("libcamera: Add members to MediaEntity to support ancillary entities")
> Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally at ideasonboard.com>
> ---
>   include/libcamera/internal/media_object.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index 9356d204d..54e2e5cef 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -112,7 +112,7 @@ public:
>   	unsigned int deviceMinor() const { return minor_; }
>   
>   	const std::vector<MediaPad *> &pads() const { return pads_; }
> -	const std::vector<MediaEntity *> ancillaryEntities() const { return ancillaryEntities_; }
> +	const std::vector<MediaEntity *> &ancillaryEntities() const { return ancillaryEntities_; }
>   
>   	const MediaPad *getPadByIndex(unsigned int index) const;
>   	const MediaPad *getPadById(unsigned int id) const;


More information about the libcamera-devel mailing list