[06/11] ipa: libipa: pwl: Make the empty() function inline
diff mbox series

Message ID 20240613013944.23344-7-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • ipa: libipa: Vector and Pwl improvements
Related show

Commit Message

Laurent Pinchart June 13, 2024, 1:39 a.m. UTC
The Pwl::empty() function is a one-liner that can be easily optimized by
the compiler given the chance. Make it inline.

While at it, move the function documentation block to match the class
declaration order.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/libipa/pwl.cpp | 15 ++++++---------
 src/ipa/libipa/pwl.h   |  2 +-
 2 files changed, 7 insertions(+), 10 deletions(-)

Comments

Paul Elder June 13, 2024, 7:38 a.m. UTC | #1
On Thu, Jun 13, 2024 at 04:39:39AM +0300, Laurent Pinchart wrote:
> The Pwl::empty() function is a one-liner that can be easily optimized by
> the compiler given the chance. Make it inline.
> 
> While at it, move the function documentation block to match the class
> declaration order.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/ipa/libipa/pwl.cpp | 15 ++++++---------
>  src/ipa/libipa/pwl.h   |  2 +-
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp
> index 1ba0108515a1..d8ea92be0a86 100644
> --- a/src/ipa/libipa/pwl.cpp
> +++ b/src/ipa/libipa/pwl.cpp
> @@ -182,6 +182,12 @@ void Pwl::prepend(double x, double y, const double eps)
>  		points_.insert(points_.begin(), Point({ x, y }));
>  }
>  
> +/**
> + * \fn Pwl::empty() const
> + * \brief Check if the piecewise linear function is empty
> + * \return True if there are no points in the function, false otherwise
> + */
> +
>  /**
>   * \brief Get the domain of the piecewise linear function
>   * \return An interval representing the domain
> @@ -203,15 +209,6 @@ Pwl::Interval Pwl::range() const
>  	return Interval(lo, hi);
>  }
>  
> -/**
> - * \brief Check if the piecewise linear function is empty
> - * \return True if there are no points in the function, false otherwise
> - */
> -bool Pwl::empty() const
> -{
> -	return points_.empty();
> -}
> -
>  /**
>   * \brief Evaluate the piecewise linear function
>   * \param[in] x The x value to input into the function
> diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h
> index 4cc257f97b19..b4de00cf88f0 100644
> --- a/src/ipa/libipa/pwl.h
> +++ b/src/ipa/libipa/pwl.h
> @@ -51,7 +51,7 @@ public:
>  
>  	void append(double x, double y, double eps = 1e-6);
>  
> -	bool empty() const;
> +	bool empty() const { return points_.empty(); }
>  	Interval domain() const;
>  	Interval range() const;
>
Kieran Bingham June 13, 2024, 11:15 a.m. UTC | #2
Quoting Laurent Pinchart (2024-06-13 02:39:39)
> The Pwl::empty() function is a one-liner that can be easily optimized by
> the compiler given the chance. Make it inline.
> 
> While at it, move the function documentation block to match the class
> declaration order.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/ipa/libipa/pwl.cpp | 15 ++++++---------
>  src/ipa/libipa/pwl.h   |  2 +-
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp
> index 1ba0108515a1..d8ea92be0a86 100644
> --- a/src/ipa/libipa/pwl.cpp
> +++ b/src/ipa/libipa/pwl.cpp
> @@ -182,6 +182,12 @@ void Pwl::prepend(double x, double y, const double eps)
>                 points_.insert(points_.begin(), Point({ x, y }));
>  }
>  
> +/**
> + * \fn Pwl::empty() const
> + * \brief Check if the piecewise linear function is empty
> + * \return True if there are no points in the function, false otherwise
> + */
> +
>  /**
>   * \brief Get the domain of the piecewise linear function
>   * \return An interval representing the domain
> @@ -203,15 +209,6 @@ Pwl::Interval Pwl::range() const
>         return Interval(lo, hi);
>  }
>  
> -/**
> - * \brief Check if the piecewise linear function is empty
> - * \return True if there are no points in the function, false otherwise
> - */
> -bool Pwl::empty() const
> -{
> -       return points_.empty();
> -}
> -
>  /**
>   * \brief Evaluate the piecewise linear function
>   * \param[in] x The x value to input into the function
> diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h
> index 4cc257f97b19..b4de00cf88f0 100644
> --- a/src/ipa/libipa/pwl.h
> +++ b/src/ipa/libipa/pwl.h
> @@ -51,7 +51,7 @@ public:
>  
>         void append(double x, double y, double eps = 1e-6);
>  
> -       bool empty() const;
> +       bool empty() const { return points_.empty(); }
>         Interval domain() const;
>         Interval range() const;
>  
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp
index 1ba0108515a1..d8ea92be0a86 100644
--- a/src/ipa/libipa/pwl.cpp
+++ b/src/ipa/libipa/pwl.cpp
@@ -182,6 +182,12 @@  void Pwl::prepend(double x, double y, const double eps)
 		points_.insert(points_.begin(), Point({ x, y }));
 }
 
+/**
+ * \fn Pwl::empty() const
+ * \brief Check if the piecewise linear function is empty
+ * \return True if there are no points in the function, false otherwise
+ */
+
 /**
  * \brief Get the domain of the piecewise linear function
  * \return An interval representing the domain
@@ -203,15 +209,6 @@  Pwl::Interval Pwl::range() const
 	return Interval(lo, hi);
 }
 
-/**
- * \brief Check if the piecewise linear function is empty
- * \return True if there are no points in the function, false otherwise
- */
-bool Pwl::empty() const
-{
-	return points_.empty();
-}
-
 /**
  * \brief Evaluate the piecewise linear function
  * \param[in] x The x value to input into the function
diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h
index 4cc257f97b19..b4de00cf88f0 100644
--- a/src/ipa/libipa/pwl.h
+++ b/src/ipa/libipa/pwl.h
@@ -51,7 +51,7 @@  public:
 
 	void append(double x, double y, double eps = 1e-6);
 
-	bool empty() const;
+	bool empty() const { return points_.empty(); }
 	Interval domain() const;
 	Interval range() const;