use switch instead of if-else to fix lint error

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
This commit is contained in:
Ziqi Zhao 2023-08-23 13:13:25 +08:00
parent 788061e509
commit 893f97556f
1 changed files with 7 additions and 6 deletions

View File

@ -998,7 +998,8 @@ func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, b
bucketsA = append(bucketsA, 0) bucketsA = append(bucketsA, 0)
copy(bucketsA[iBucket+1:], bucketsA[iBucket:]) copy(bucketsA[iBucket+1:], bucketsA[iBucket:])
bucketsA[iBucket] = bucketB bucketsA[iBucket] = bucketB
if deltaIndex == 0 { switch {
case deltaIndex == 0:
// Directly after previous span, extend previous span. // Directly after previous span, extend previous span.
if iSpan < len(spansA) { if iSpan < len(spansA) {
spansA[iSpan].Offset-- spansA[iSpan].Offset--
@ -1006,14 +1007,14 @@ func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, b
iSpan-- iSpan--
iInSpan = int32(spansA[iSpan].Length) iInSpan = int32(spansA[iSpan].Length)
spansA[iSpan].Length++ spansA[iSpan].Length++
break goto nextLoop
} else if iSpan < len(spansA) && deltaIndex == spansA[iSpan].Offset-1 { case iSpan < len(spansA) && deltaIndex == spansA[iSpan].Offset-1:
// Directly before next span, extend next span. // Directly before next span, extend next span.
iInSpan = 0 iInSpan = 0
spansA[iSpan].Offset-- spansA[iSpan].Offset--
spansA[iSpan].Length++ spansA[iSpan].Length++
break goto nextLoop
} else { default:
// No next span, or next span is not directly adjacent to new bucket. // No next span, or next span is not directly adjacent to new bucket.
// Add new span. // Add new span.
iInSpan = 0 iInSpan = 0
@ -1023,7 +1024,7 @@ func addBuckets(schema int32, threshold float64, negative bool, spansA []Span, b
spansA = append(spansA, Span{}) spansA = append(spansA, Span{})
copy(spansA[iSpan+1:], spansA[iSpan:]) copy(spansA[iSpan+1:], spansA[iSpan:])
spansA[iSpan] = Span{Length: 1, Offset: deltaIndex} spansA[iSpan] = Span{Length: 1, Offset: deltaIndex}
break goto nextLoop
} }
} else { } else {
// Try start of next span. // Try start of next span.