ipa: libipa: pwl: Add a constructor that moves a Point vector

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@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2024-06-13 04:12:29 +03:00
parent 0706c67711
commit 31c9998bf0
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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);