From 893f97556f7648821121180fb8e8fb0f2aa58053 Mon Sep 17 00:00:00 2001 From: Ziqi Zhao Date: Wed, 23 Aug 2023 13:13:25 +0800 Subject: [PATCH] use switch instead of if-else to fix lint error Signed-off-by: Ziqi Zhao --- model/histogram/float_histogram.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/model/histogram/float_histogram.go b/model/histogram/float_histogram.go index 539ee73b9..360fa6823 100644 --- a/model/histogram/float_histogram.go +++ b/model/histogram/float_histogram.go @@ -998,7 +998,8 @@ func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, b bucketsA = append(bucketsA, 0) copy(bucketsA[iBucket+1:], bucketsA[iBucket:]) bucketsA[iBucket] = bucketB - if deltaIndex == 0 { + switch { + case deltaIndex == 0: // Directly after previous span, extend previous span. if iSpan < len(spansA) { spansA[iSpan].Offset-- @@ -1006,14 +1007,14 @@ func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, b iSpan-- iInSpan = int32(spansA[iSpan].Length) spansA[iSpan].Length++ - break - } else if iSpan < len(spansA) && deltaIndex == spansA[iSpan].Offset-1 { + goto nextLoop + case iSpan < len(spansA) && deltaIndex == spansA[iSpan].Offset-1: // Directly before next span, extend next span. iInSpan = 0 spansA[iSpan].Offset-- spansA[iSpan].Length++ - break - } else { + goto nextLoop + default: // No next span, or next span is not directly adjacent to new bucket. // Add new span. iInSpan = 0 @@ -1023,7 +1024,7 @@ func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, b spansA = append(spansA, Span{}) copy(spansA[iSpan+1:], spansA[iSpan:]) spansA[iSpan] = Span{Length: 1, Offset: deltaIndex} - break + goto nextLoop } } else { // Try start of next span.