From 7d352f8acc4307a89c39dc31617a321bd7a8f426 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 13 Sep 2023 07:39:36 +0200 Subject: [PATCH] metrics: oblige nitpicks from review --- metrics/sample.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/metrics/sample.go b/metrics/sample.go index 152ad0de7b..5398dd42d5 100644 --- a/metrics/sample.go +++ b/metrics/sample.go @@ -83,14 +83,14 @@ func (s *ExpDecaySample) Clear() { func (s *ExpDecaySample) Snapshot() SampleSnapshot { s.mutex.Lock() defer s.mutex.Unlock() - vals := s.values.Values() - values := make([]int64, len(vals)) var ( - max int64 = math.MinInt64 - min int64 = math.MaxInt64 - sum int64 + samples = s.values.Values() + values = make([]int64, len(samples)) + max int64 = math.MinInt64 + min int64 = math.MaxInt64 + sum int64 ) - for i, item := range vals { + for i, item := range samples { v := item.v values[i] = v sum += v @@ -196,8 +196,7 @@ type sampleSnapshot struct { // newSampleSnapshotPrecalculated creates a read-only sampleSnapShot, using // precalculated sums to avoid iterating the values -func newSampleSnapshotPrecalculated(count int64, values []int64, - min, max, sum int64) *sampleSnapshot { +func newSampleSnapshotPrecalculated(count int64, values []int64, min, max, sum int64) *sampleSnapshot { if len(values) == 0 { return &sampleSnapshot{ count: count,