Skip to content

Commit 3f18862

Browse files
authored
util: Check context every N iterations (#6250)
1 parent 53556fe commit 3f18862

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/util/strings.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ func MergeSortedSlices(ctx context.Context, a ...[]string) ([]string, error) {
129129

130130
r := make([]string, 0, sumLengh*2/10)
131131
var current string
132+
cnt := 0
132133
for lt.Next() {
133-
if ctx.Err() != nil {
134+
cnt++
135+
if cnt%CheckContextEveryNIterations == 0 && ctx.Err() != nil {
134136
return nil, ctx.Err()
135137
}
136138
if lt.At() != current {

0 commit comments

Comments
 (0)