From c1939b713602b6752150d3fd1b974f022baeec58 Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Fri, 5 May 2017 19:34:59 +0530 Subject: [PATCH] Simply loop away from using tracking variables. Signed-off-by: Goutham Veeramachaneni --- querier.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/querier.go b/querier.go index a0276b2305..97970e8309 100644 --- a/querier.go +++ b/querier.go @@ -413,12 +413,15 @@ func (s *populatedChunkSeries) Next() bool { for s.set.Next() { lset, chks := s.set.At() - from := -1 - for i, c := range chks { - if c.MaxTime < s.mint { - from = i - continue + for len(chks) > 0 { + if chks[0].MaxTime >= s.mint { + break } + chks = chks[1:] + } + + // Break out at the first chunk that has no overlap with mint, maxt. + for i, c := range chks { if c.MinTime > s.maxt { chks = chks[:i] break @@ -429,7 +432,6 @@ func (s *populatedChunkSeries) Next() bool { } } - chks = chks[from+1:] if len(chks) == 0 { continue }