Skip to content

Commit

Permalink
refactor(store,x/params): using maps.Copy (#19889)
Browse files Browse the repository at this point in the history
Co-authored-by: weixie.c <[email protected]>
  • Loading branch information
cuiweixie and weixiecui authored Mar 28, 2024
1 parent f630cfb commit 705fad6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions store/trace.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package store

import "golang.org/x/exp/maps"
import "maps"

// TraceContext contains KVStore context data. It will be written with every
// trace operation.
Expand All @@ -17,9 +17,7 @@ func (tc TraceContext) Merge(newTc TraceContext) TraceContext {
tc = TraceContext{}
}

for k, v := range newTc {
tc[k] = v
}
maps.Copy(tc, newTc)

return tc
}
5 changes: 2 additions & 3 deletions x/params/types/subspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"maps"
"reflect"

"cosmossdk.io/store/prefix"
Expand Down Expand Up @@ -57,9 +58,7 @@ func (s Subspace) WithKeyTable(table KeyTable) Subspace {
panic("WithKeyTable() called on already initialized Subspace")
}

for k, v := range table.m {
s.table.m[k] = v
}
maps.Copy(s.table.m, table.m)

// Allocate additional capacity for Subspace.name
// So we don't have to allocate extra space each time appending to the key
Expand Down

0 comments on commit 705fad6

Please sign in to comment.