From 8c295bf55feaa07cd487e6015029c4682a1480b0 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Fri, 13 Sep 2024 00:26:29 +0800 Subject: [PATCH] encoding/gob: make use of maps.Clone Change-Id: I4e9a7fd1dd3275c3da5500c9c4bf687b77f53107 --- src/encoding/gob/type.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/encoding/gob/type.go b/src/encoding/gob/type.go index c3ac1dbd61..a26070713f 100644 --- a/src/encoding/gob/type.go +++ b/src/encoding/gob/type.go @@ -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