From 31c9998bf042963f11e0c4f3687ee8ba0b7318cc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 13 Jun 2024 04:12:29 +0300 Subject: ipa: libipa: pwl: Add a constructor that moves a Point vector The Pwl::Pwl(const std::vector &) 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 Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/ipa/libipa/pwl.cpp | 11 +++++++++++ src/ipa/libipa/pwl.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src/ipa/libipa') diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 8b437dd1..cf864fbb 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -114,6 +114,17 @@ Pwl::Pwl(const std::vector &points) { } +/** + * \copydoc Pwl::Pwl(const std::vector &points) + * + * The contents of the \a points vector is moved to the newly constructed Pwl + * instance. + */ +Pwl::Pwl(std::vector &&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 02834231..8edb4d33 100644 --- a/src/ipa/libipa/pwl.h +++ b/src/ipa/libipa/pwl.h @@ -47,6 +47,8 @@ public: Pwl(); Pwl(const std::vector &points); + Pwl(std::vector &&points); + int readYaml(const libcamera::YamlObject ¶ms); void append(double x, double y, double eps = 1e-6); -- cgit v1.2.1