diff options
| author | Jes Cok <xigua67damn@gmail.com> | 2024-09-13 13:48:33 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-09-13 21:05:31 +0000 |
| commit | 0a2cc74f5a12b5cb7945e620a871b073b95ebee7 (patch) | |
| tree | de326f2429632a8e159a1df6432612232bf94c00 /src/cmd/fix | |
| parent | 76e44f42c819e0fdd23918ea05a96b1f2d764de7 (diff) | |
| download | go-0a2cc74f5a12b5cb7945e620a871b073b95ebee7.tar.xz | |
cmd: make use of maps.{Copy, Clone}
Change-Id: I8a38b4c71c34d3544ee32be9c6e767bb1099a720
GitHub-Last-Rev: ff4cb4e91be3936465635f99d061f02999640ed9
GitHub-Pull-Request: golang/go#69424
Reviewed-on: https://go-review.googlesource.com/c/go/+/612735
Reviewed-by: Keith Randall <khr@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/fix')
| -rw-r--r-- | src/cmd/fix/typecheck.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/fix/typecheck.go b/src/cmd/fix/typecheck.go index b115987390..be21582fce 100644 --- a/src/cmd/fix/typecheck.go +++ b/src/cmd/fix/typecheck.go @@ -9,6 +9,7 @@ import ( "go/ast" "go/parser" "go/token" + "maps" "os" "os/exec" "path/filepath" @@ -272,9 +273,9 @@ func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[any]string, assign map[ if !copied { copied = true // Copy map lazily: it's time. - cfg1.Type = make(map[string]*Type) - for k, v := range cfg.Type { - cfg1.Type[k] = v + cfg1.Type = maps.Clone(cfg.Type) + if cfg1.Type == nil { + cfg1.Type = make(map[string]*Type) } } t := &Type{Field: map[string]string{}} |
