Message ID | 20240613013944.23344-9-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
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@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@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);
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@ideasonboard.com> > Signed-off-by: Laurent Pinchart <laurent.pinchart@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); > -- > Regards, > > Laurent Pinchart >
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);
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> --- src/ipa/libipa/pwl.cpp | 11 +++++++++++ src/ipa/libipa/pwl.h | 2 ++ 2 files changed, 13 insertions(+)