Skip to content

Commit c4912f0

Browse files
committed
kvstorage: use slices and maps helpers
Epic: none Release note: none
1 parent 23e6dab commit c4912f0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pkg/kv/kvserver/kvstorage/init.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"bytes"
1010
"cmp"
1111
"context"
12+
"maps"
1213
"slices"
1314
"time"
1415

@@ -531,10 +532,7 @@ func loadReplicas(ctx context.Context, eng storage.Engine) ([]Replica, error) {
531532
}
532533
log.KvExec.Infof(ctx, "loaded state for %d/%d replicas", len(s), len(s))
533534

534-
sl := make([]Replica, 0, len(s))
535-
for _, repl := range s {
536-
sl = append(sl, repl)
537-
}
535+
sl := slices.AppendSeq(make([]Replica, 0, len(s)), maps.Values(s))
538536
slices.SortFunc(sl, func(a, b Replica) int {
539537
return cmp.Compare(a.RangeID, b.RangeID)
540538
})

0 commit comments

Comments
 (0)