[libcamera-devel] [PATCH v1] libcamera: framebuffer_allocator: Remove unnecessary `clear()`

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Jan 9 14:11:19 CET 2024


Quoting Barnabás Pőcze via libcamera-devel (2023-12-09 02:22:28)
> The vector in question is destroyed when the item in the `buffers_` map
> is destroyed as a result of the `erase()` call. A vector's destructor
> already does all the things that `clear()` does,
> so calling it earlier is not needed.

This looks correct to me. I guess it's a micro-optimisation, but it
seems valid.

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>
> ---
>  src/libcamera/framebuffer_allocator.cpp | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp
> index dabd9219..94389735 100644
> --- a/src/libcamera/framebuffer_allocator.cpp
> +++ b/src/libcamera/framebuffer_allocator.cpp
> @@ -121,8 +121,6 @@ int FrameBufferAllocator::free(Stream *stream)
>         if (iter == buffers_.end())
>                 return -EINVAL;
>  
> -       std::vector<std::unique_ptr<FrameBuffer>> &buffers = iter->second;
> -       buffers.clear();
>         buffers_.erase(iter);
>  
>         return 0;
> -- 
> 2.43.0
> 
>


More information about the libcamera-devel mailing list