Message ID | 20251014142427.3107490-2-stefan.klug@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
2025. 10. 14. 16:24 keltezéssel, Stefan Klug írta: > Add a swap() function to easily swap the contents of two PWLs. > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> > --- It looks OK, although I believe all use-cases in this patch series can be replaced with the already generated move assignment operator. Maybe I am missing some other reason? But if it is need: Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > src/ipa/libipa/pwl.cpp | 6 ++++++ > src/ipa/libipa/pwl.h | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp > index 69a9334112e8..1858ab37b101 100644 > --- a/src/ipa/libipa/pwl.cpp > +++ b/src/ipa/libipa/pwl.cpp > @@ -169,6 +169,12 @@ void Pwl::prepend(double x, double y, const double eps) > * \return The number of points in the piecewise linear function > */ > > +/** > + * \fn Pwl::swap(Pwl &other) > + * \brief Swap the contents with another PWL > + * \param[in] other The PWL to swap with > + */ > + > /** > * \brief Get the domain of the piecewise linear function > * \return An interval representing the domain > diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h > index c1496c300ee0..add20b5867af 100644 > --- a/src/ipa/libipa/pwl.h > +++ b/src/ipa/libipa/pwl.h > @@ -51,6 +51,7 @@ public: > bool empty() const { return points_.empty(); } > void clear() { points_.clear(); } > size_t size() const { return points_.size(); } > + void swap(Pwl &other) { points_.swap(other.points_); } > > Interval domain() const; > Interval range() const;
diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 69a9334112e8..1858ab37b101 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -169,6 +169,12 @@ void Pwl::prepend(double x, double y, const double eps) * \return The number of points in the piecewise linear function */ +/** + * \fn Pwl::swap(Pwl &other) + * \brief Swap the contents with another PWL + * \param[in] other The PWL to swap with + */ + /** * \brief Get the domain of the piecewise linear function * \return An interval representing the domain diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h index c1496c300ee0..add20b5867af 100644 --- a/src/ipa/libipa/pwl.h +++ b/src/ipa/libipa/pwl.h @@ -51,6 +51,7 @@ public: bool empty() const { return points_.empty(); } void clear() { points_.clear(); } size_t size() const { return points_.size(); } + void swap(Pwl &other) { points_.swap(other.points_); } Interval domain() const; Interval range() const;
Add a swap() function to easily swap the contents of two PWLs. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- src/ipa/libipa/pwl.cpp | 6 ++++++ src/ipa/libipa/pwl.h | 1 + 2 files changed, 7 insertions(+)