Skip to content

Commit

Permalink
util: Check context every N iterations (#6250)
Browse files Browse the repository at this point in the history
  • Loading branch information
harry671003 authored Oct 3, 2024
1 parent 53556fe commit 3f18862
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/util/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ func MergeSortedSlices(ctx context.Context, a ...[]string) ([]string, error) {

r := make([]string, 0, sumLengh*2/10)
var current string
cnt := 0
for lt.Next() {
if ctx.Err() != nil {
cnt++
if cnt%CheckContextEveryNIterations == 0 && ctx.Err() != nil {
return nil, ctx.Err()
}
if lt.At() != current {
Expand Down

0 comments on commit 3f18862

Please sign in to comment.