[v4,34/49] ipa: libipa: histogram: total(): Use `back()`
diff mbox series

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

Commit Message

Barnabás Pőcze Aug. 10, 2026, 10:38 a.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>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/histogram.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Klug Aug. 12, 2026, 9:56 a.m. UTC | #1
Hi Barnabás,

Quoting Barnabás Pőcze (2026-08-10 12:38:30)
> 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>
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>

Cheers,
Stefan

> ---
>  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;