[RFC,v2,30/43] ipa: libipa: histogram: total(): Use `back()`
diff mbox series

Message ID 20260723154327.1357866-31-barnabas.pocze@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: libipa: agc rework
Related show

Commit Message

Barnabás Pőcze July 23, 2026, 3:43 p.m. UTC
Use the back method of `std::vector` to get the last element
instead of indexing; this is clearer.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/libipa/histogram.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi July 27, 2026, 3 p.m. UTC | #1
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

On Thu, Jul 23, 2026 at 05:43:13PM +0200, Barnabás Pőcze wrote:
> Use the back method of `std::vector` to get the last element
> instead of indexing; this is clearer.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/ipa/libipa/histogram.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h
> index 8cf8bb6d16..0c02dda2ba 100644
> --- a/src/ipa/libipa/histogram.h
> +++ b/src/ipa/libipa/histogram.h
> @@ -37,7 +37,7 @@ public:
>
>  	size_t bins() const { return cumulative_.size() - 1; }
>  	Span<const uint64_t> data() const { return cumulative_; }
> -	uint64_t total() const { return cumulative_[cumulative_.size() - 1]; }
> +	uint64_t total() const { return cumulative_.back(); }
>  	uint64_t cumulativeFrequency(double bin) const;
>  	double quantile(double q, uint32_t first = 0, uint32_t last = UINT_MAX) const;
>  	double interQuantileMean(double lowQuantile, double hiQuantile) const;
> --
> 2.55.0
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h
index 8cf8bb6d16..0c02dda2ba 100644
--- a/src/ipa/libipa/histogram.h
+++ b/src/ipa/libipa/histogram.h
@@ -37,7 +37,7 @@  public:
 
 	size_t bins() const { return cumulative_.size() - 1; }
 	Span<const uint64_t> data() const { return cumulative_; }
-	uint64_t total() const { return cumulative_[cumulative_.size() - 1]; }
+	uint64_t total() const { return cumulative_.back(); }
 	uint64_t cumulativeFrequency(double bin) const;
 	double quantile(double q, uint32_t first = 0, uint32_t last = UINT_MAX) const;
 	double interQuantileMean(double lowQuantile, double hiQuantile) const;