[PATCH v1] apps: qcam: Simplify `PixelFormat` search

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Mar 4 11:05:35 CET 2025


Quoting Barnabás Pőcze (2025-03-03 19:33:39)
> Since `PixelFormat` has `operator==()`, `std::find()` can be used
> directly, so do that to simplify.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>

I'm curious if this was possible when the auto match was added in the
first place, or if the operator==() came later, but either way - no need
to go into archeology for this so:


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

> ---
>  src/apps/qcam/main_window.cpp | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
> index 3880a846e..d2ccbd231 100644
> --- a/src/apps/qcam/main_window.cpp
> +++ b/src/apps/qcam/main_window.cpp
> @@ -386,10 +386,7 @@ int MainWindow::startCapture()
>         /* Use a format supported by the viewfinder if available. */
>         std::vector<PixelFormat> formats = vfConfig.formats().pixelformats();
>         for (const PixelFormat &format : viewfinder_->nativeFormats()) {
> -               auto match = std::find_if(formats.begin(), formats.end(),
> -                                         [&](const PixelFormat &f) {
> -                                                 return f == format;
> -                                         });
> +               auto match = std::find(formats.begin(), formats.end(), format);
>                 if (match != formats.end()) {
>                         vfConfig.pixelFormat = format;
>                         break;
> -- 
> 2.48.1
>


More information about the libcamera-devel mailing list