[PATCH 08/11] ipa: libipa: pwl: Add a constructor that moves a Point vector
Paul Elder
paul.elder at ideasonboard.com
Thu Jun 13 09:55:39 CEST 2024
On Thu, Jun 13, 2024 at 04:39:41AM +0300, Laurent Pinchart wrote:
> 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.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder 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 ¶ms);
>
> void append(double x, double y, double eps = 1e-6);
More information about the libcamera-devel
mailing list