From 8a83c59956458ae2a2b302f9e5046d8cf18d64fe Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 26 Jul 2022 19:20:42 +0300 Subject: [PATCH] app/vmselect/promql: reduce the diff for f148cffc8ad08a36a08e72c7d3c56d4c49859fb3 This is a follow-up for c826f0636631088a552629e804ea3c2628a54eeb --- app/vmselect/promql/transform.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index 02257cc5ca..c3a06735ee 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -572,22 +572,23 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries { }) } xss = xssNew - if len(xss) > 0 { - for i := range xss[0].ts.Values { - count := float64(0) - for _, xs := range xss { - ts := xs.ts - v := ts.Values[i] - if !math.IsNaN(v) && v > 0 { - count += v - } - ts.Values[i] = count - } - } + if len(xss) == 0 { + continue + } + for i := range xss[0].ts.Values { + count := float64(0) for _, xs := range xss { - rvs = append(rvs, xs.ts) + ts := xs.ts + v := ts.Values[i] + if !math.IsNaN(v) && v > 0 { + count += v + } + ts.Values[i] = count } } + for _, xs := range xss { + rvs = append(rvs, xs.ts) + } } return rvs }