Skip to content

Commit 4942b88

Browse files
committed
Remove custom map cloning function
1 parent aa03b96 commit 4942b88

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

pbm/restore/physical.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
slog "log"
10+
"maps"
1011
"math/rand"
1112
"net"
1213
"os"
@@ -508,7 +509,7 @@ func (r *PhysRestore) toState(status defs.Status) (_ defs.Status, err error) {
508509

509510
if r.nodeInfo.IsPrimary || status == defs.StatusDone {
510511
r.log.Info("waiting for `%s` status in rs %v", status, r.syncPathPeers)
511-
cstat, err := r.waitFiles(status, copyMap(r.syncPathPeers), false)
512+
cstat, err := r.waitFiles(status, maps.Clone(r.syncPathPeers), false)
512513
if err != nil {
513514
return defs.StatusError, errors.Wrap(err, "wait for nodes in rs")
514515
}
@@ -521,7 +522,7 @@ func (r *PhysRestore) toState(status defs.Status) (_ defs.Status, err error) {
521522

522523
if r.nodeInfo.IsClusterLeader() || status == defs.StatusDone {
523524
r.log.Info("waiting for shards %v", r.syncPathShards)
524-
cstat, err := r.waitFiles(status, copyMap(r.syncPathShards), true)
525+
cstat, err := r.waitFiles(status, maps.Clone(r.syncPathShards), true)
525526
if err != nil {
526527
return defs.StatusError, errors.Wrap(err, "wait for shards")
527528
}
@@ -592,15 +593,6 @@ func (n nodeError) Error() string {
592593
return fmt.Sprintf("%s failed: %s", n.node, n.msg)
593594
}
594595

595-
func copyMap[K comparable, V any](m map[K]V) map[K]V {
596-
cp := make(map[K]V)
597-
for k, v := range m {
598-
cp[k] = v
599-
}
600-
601-
return cp
602-
}
603-
604596
func (r *PhysRestore) waitFiles(
605597
status defs.Status,
606598
objs map[string]struct{},
@@ -1717,7 +1709,7 @@ func (r *PhysRestore) agreeCommonRestoreTS() (primitive.Timestamp, error) {
17171709
}
17181710

17191711
if r.nodeInfo.IsClusterLeader() {
1720-
_, err := r.waitFiles(defs.StatusExtTS, copyMap(r.syncPathShards), true)
1712+
_, err := r.waitFiles(defs.StatusExtTS, maps.Clone(r.syncPathShards), true)
17211713
if err != nil {
17221714
return ts, errors.Wrap(err, "wait for shards timestamp")
17231715
}
@@ -1766,7 +1758,7 @@ func (r *PhysRestore) setcommittedTxn(_ context.Context, txn []phys.RestoreTxn)
17661758
}
17671759

17681760
func (r *PhysRestore) getcommittedTxn(context.Context) (map[string]primitive.Timestamp, error) {
1769-
shards := copyMap(r.syncPathShards)
1761+
shards := maps.Clone(r.syncPathShards)
17701762
txn := make(map[string]primitive.Timestamp)
17711763
for len(shards) > 0 {
17721764
for f := range shards {

0 commit comments

Comments
 (0)