From a685502107f27fc38d39e40f13ff79bd9e64d085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Krajcsovits?= Date: Fri, 14 Jul 2023 12:29:41 +0200 Subject: [PATCH] Simplify code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: György Krajcsovits --- .../prometheusremotewrite/histograms_test.go | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/pkg/translator/prometheusremotewrite/histograms_test.go b/pkg/translator/prometheusremotewrite/histograms_test.go index 34003d3048ec..49e4768e5383 100644 --- a/pkg/translator/prometheusremotewrite/histograms_test.go +++ b/pkg/translator/prometheusremotewrite/histograms_test.go @@ -583,24 +583,16 @@ func validateNativeHistogramCount(t *testing.T, h prompb.Histogram) { want := h.Count.(*prompb.Histogram_CountInt).CountInt var ( actualCount uint64 - prevCount int64 + prevBucket int64 ) - for i, delta := range h.PositiveDeltas { - if i == 0 { - actualCount += uint64(delta) - } else { - actualCount += uint64(prevCount + delta) - } - prevCount += delta + for _, delta := range h.PositiveDeltas { + prevBucket += delta + actualCount += uint64(prevBucket) } - prevCount = 0 - for i, delta := range h.NegativeDeltas { - if i == 0 { - actualCount += uint64(delta) - } else { - actualCount += uint64(prevCount + delta) - } - prevCount += delta + prevBucket = 0 + for _, delta := range h.NegativeDeltas { + prevBucket += delta + actualCount += uint64(prevBucket) } assert.Equal(t, want, actualCount, "native histogram count mismatch") }