histograms: avoid initialization tracking in reverseFloatBucketIterator
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
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
|
||||||
}
|
}
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *reverseFloatBucketIterator) Next() bool {
|
|
||||||
if !r.initiated {
|
|
||||||
r.initiated = true
|
|
||||||
r.spansIdx = len(r.spans) - 1
|
r.spansIdx = len(r.spans) - 1
|
||||||
r.bucketsIdx = len(r.buckets) - 1
|
r.bucketsIdx = len(r.buckets) - 1
|
||||||
if r.spansIdx >= 0 {
|
if r.spansIdx >= 0 {
|
||||||
r.idxInSpan = int32(r.spans[r.spansIdx].Length) - 1
|
r.idxInSpan = int32(r.spans[r.spansIdx].Length) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
r.currIdx = 0
|
r.currIdx = 0
|
||||||
for _, s := range r.spans {
|
for _, s := range r.spans {
|
||||||
r.currIdx += s.Offset + int32(s.Length)
|
r.currIdx += s.Offset + int32(s.Length)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *reverseFloatBucketIterator) Next() bool {
|
||||||
r.currIdx--
|
r.currIdx--
|
||||||
if r.bucketsIdx < 0 {
|
if r.bucketsIdx < 0 {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue