1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:47:56 -07:00

encoding/gob: make use of maps.Clone

Change-Id: I6a23219a9e05350bdd9205e19165d5944f15de31
GitHub-Last-Rev: 8c295bf55f
GitHub-Pull-Request: golang/go#69429
Reviewed-on: https://go-review.googlesource.com/c/go/+/612719
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Jes Cok 2024-09-13 13:14:51 +00:00 committed by Gopher Robot
parent bc7c35a6d3
commit 76e44f42c8

View File

@ -8,6 +8,7 @@ import (
"encoding"
"errors"
"fmt"
"maps"
"os"
"reflect"
"sync"
@ -779,10 +780,7 @@ func buildTypeInfo(ut *userTypeInfo, rt reflect.Type) (*typeInfo, error) {
// Create new map with old contents plus new entry.
m, _ := typeInfoMap.Load().(map[reflect.Type]*typeInfo)
newm := make(map[reflect.Type]*typeInfo, len(m))
for k, v := range m {
newm[k] = v
}
newm := maps.Clone(m)
newm[rt] = info
typeInfoMap.Store(newm)
return info, nil