Skip to content

Commit f03096e

Browse files
committed
review: use min builtin in SplitRanges
1 parent 1865adb commit f03096e

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

utils/httprange.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ func SplitRanges(size int64, n int) [][2]int64 {
1313
chunk := (size + int64(n) - 1) / int64(n)
1414
ranges := make([][2]int64, 0, n)
1515
for start := int64(0); start < size; start += chunk {
16-
end := start + chunk - 1
17-
if end >= size {
18-
end = size - 1
19-
}
20-
ranges = append(ranges, [2]int64{start, end})
16+
ranges = append(ranges, [2]int64{start, min(start+chunk-1, size-1)})
2117
}
2218
return ranges
2319
}

0 commit comments

Comments
 (0)