Skip to content

Commit 8828185

Browse files
json: use maps.Copy
1 parent fc8ac4c commit 8828185

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

json/codec.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding"
55
"encoding/json"
66
"fmt"
7+
"maps"
78
"math/big"
89
"reflect"
910
"sort"
@@ -73,12 +74,9 @@ func cacheLoad() map[unsafe.Pointer]codec {
7374

7475
func cacheStore(typ reflect.Type, cod codec, oldCodecs map[unsafe.Pointer]codec) {
7576
newCodecs := make(map[unsafe.Pointer]codec, len(oldCodecs)+1)
77+
maps.Copy(newCodecs, oldCodecs)
7678
newCodecs[typeid(typ)] = cod
7779

78-
for t, c := range oldCodecs {
79-
newCodecs[t] = c
80-
}
81-
8280
cache.Store(&newCodecs)
8381
}
8482

0 commit comments

Comments
 (0)