]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/gob: make use of maps.Clone
authorJes Cok <xigua67damn@gmail.com>
Fri, 13 Sep 2024 13:14:51 +0000 (13:14 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 13 Sep 2024 21:04:06 +0000 (21:04 +0000)
Change-Id: I6a23219a9e05350bdd9205e19165d5944f15de31
GitHub-Last-Rev: 8c295bf55feaa07cd487e6015029c4682a1480b0
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>
src/encoding/gob/type.go

index c3ac1dbd61fd51b245a433eae445251fd3a539bb..a26070713f8be8155b553759a4f072dbf18d8a31 100644 (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