mirror of
https://github.com/golang/go
synced 2024-11-14 05:40:29 -07:00
encoding/gob: make use of maps.Clone
Change-Id: I4e9a7fd1dd3275c3da5500c9c4bf687b77f53107
This commit is contained in:
parent
8a4b439ee6
commit
8c295bf55f
@ -8,6 +8,7 @@ import (
|
|||||||
"encoding"
|
"encoding"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
@ -779,10 +780,7 @@ func buildTypeInfo(ut *userTypeInfo, rt reflect.Type) (*typeInfo, error) {
|
|||||||
|
|
||||||
// Create new map with old contents plus new entry.
|
// Create new map with old contents plus new entry.
|
||||||
m, _ := typeInfoMap.Load().(map[reflect.Type]*typeInfo)
|
m, _ := typeInfoMap.Load().(map[reflect.Type]*typeInfo)
|
||||||
newm := make(map[reflect.Type]*typeInfo, len(m))
|
newm := maps.Clone(m)
|
||||||
for k, v := range m {
|
|
||||||
newm[k] = v
|
|
||||||
}
|
|
||||||
newm[rt] = info
|
newm[rt] = info
|
||||||
typeInfoMap.Store(newm)
|
typeInfoMap.Store(newm)
|
||||||
return info, nil
|
return info, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user