[PATCH 08/11] ipa: libipa: pwl: Add a constructor that moves a Point vector

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Jun 13 13:17:27 CEST 2024


Quoting Laurent Pinchart (2024-06-13 02:39:41)
> The Pwl::Pwl(const std::vector<Point> &) constructor is inefficient as
> it makes a copy of the given points vector. Add a second constructor
> that takes an rvalue reference to a points vector to provide move
> semantics.
> 

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

> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/ipa/libipa/pwl.cpp | 11 +++++++++++
>  src/ipa/libipa/pwl.h   |  2 ++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp
> index 8b437dd1a650..cf864fbb3889 100644
> --- a/src/ipa/libipa/pwl.cpp
> +++ b/src/ipa/libipa/pwl.cpp
> @@ -114,6 +114,17 @@ Pwl::Pwl(const std::vector<Point> &points)
>  {
>  }
>  
> +/**
> + * \copydoc Pwl::Pwl(const std::vector<Point> &points)
> + *
> + * The contents of the \a points vector is moved to the newly constructed Pwl
> + * instance.
> + */
> +Pwl::Pwl(std::vector<Point> &&points)
> +       : points_(std::move(points))
> +{
> +}
> +
>  /**
>   * \brief Populate the piecewise linear function from yaml data
>   * \param[in] params Yaml data to populate the piecewise linear function with
> diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h
> index 028342314fca..8edb4d33dc71 100644
> --- a/src/ipa/libipa/pwl.h
> +++ b/src/ipa/libipa/pwl.h
> @@ -47,6 +47,8 @@ public:
>  
>         Pwl();
>         Pwl(const std::vector<Point> &points);
> +       Pwl(std::vector<Point> &&points);
> +
>         int readYaml(const libcamera::YamlObject &params);
>  
>         void append(double x, double y, double eps = 1e-6);
> -- 
> Regards,
> 
> Laurent Pinchart
>


More information about the libcamera-devel mailing list