histograms: avoid initialization tracking in reverseFloatBucketIterator

Signed-off-by: beorn7 <beorn@grafana.com>
pull/10026/head
beorn7 3 years ago
parent a6acdfe346
commit 27f865ec49

@ -584,8 +584,6 @@ type reverseFloatBucketIterator struct {
currCount float64 // Count in the current bucket. currCount float64 // Count in the current bucket.
currIdx int32 // The actual bucket index. currIdx int32 // The actual bucket index.
currLower, currUpper float64 // Limits of the current bucket. currLower, currUpper float64 // Limits of the current bucket.
initiated bool
} }
func newReverseFloatBucketIterator(h *FloatHistogram, positive bool) *reverseFloatBucketIterator { func newReverseFloatBucketIterator(h *FloatHistogram, positive bool) *reverseFloatBucketIterator {
@ -597,24 +595,21 @@ func newReverseFloatBucketIterator(h *FloatHistogram, positive bool) *reverseFlo
r.spans = h.NegativeSpans r.spans = h.NegativeSpans
r.buckets = h.NegativeBuckets r.buckets = h.NegativeBuckets
} }
r.spansIdx = len(r.spans) - 1
r.bucketsIdx = len(r.buckets) - 1
if r.spansIdx >= 0 {
r.idxInSpan = int32(r.spans[r.spansIdx].Length) - 1
}
r.currIdx = 0
for _, s := range r.spans {
r.currIdx += s.Offset + int32(s.Length)
}
return r return r
} }
func (r *reverseFloatBucketIterator) Next() bool { func (r *reverseFloatBucketIterator) Next() bool {
if !r.initiated {
r.initiated = true
r.spansIdx = len(r.spans) - 1
r.bucketsIdx = len(r.buckets) - 1
if r.spansIdx >= 0 {
r.idxInSpan = int32(r.spans[r.spansIdx].Length) - 1
}
r.currIdx = 0
for _, s := range r.spans {
r.currIdx += s.Offset + int32(s.Length)
}
}
r.currIdx-- r.currIdx--
if r.bucketsIdx < 0 { if r.bucketsIdx < 0 {
return false return false

Loading…
Cancel
Save