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>
"go/token"
"internal/buildcfg"
"io"
+ "maps"
"os"
"path/filepath"
"reflect"
}
// merge nocallback & noescape
- for k, v := range f.NoCallbacks {
- p.noCallbacks[k] = v
- }
- for k, v := range f.NoEscapes {
- p.noEscapes[k] = v
- }
+ maps.Copy(p.noCallbacks, f.NoCallbacks)
+ maps.Copy(p.noEscapes, f.NoEscapes)
if f.ExpFunc != nil {
p.ExpFunc = append(p.ExpFunc, f.ExpFunc...)
"cmd/compile/internal/types"
"cmd/internal/pgo"
"fmt"
+ "maps"
"os"
)
// package build by VisitIR. We want to filter for local functions
// below, but we also add unknown callees to IRNodes as we go. So make
// an initial copy of IRNodes to recall just the local functions.
- localNodes := make(map[string]*IRNode, len(g.IRNodes))
- for k, v := range g.IRNodes {
- localNodes[k] = v
- }
+ localNodes := maps.Clone(g.IRNodes)
// N.B. We must consider edges in a stable order because export data
// lookup order (LookupMethodFunc, below) can impact the export data of
"go/ast"
"go/parser"
"go/token"
+ "maps"
"os"
"os/exec"
"path/filepath"
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{}}
"fmt"
"go/build"
"internal/godebugs"
+ "maps"
"sort"
"strconv"
"strings"
defaults := godebugForGoVersion(goVersion)
if defaults != nil {
// Apply m on top of defaults.
- for k, v := range m {
- defaults[k] = v
- }
+ maps.Copy(defaults, m)
m = defaults
}
"go/parser"
"go/token"
"internal/lazytemplate"
+ "maps"
"path/filepath"
"slices"
"sort"
if testEmbed == nil && len(p.Internal.Embed) > 0 {
testEmbed = map[string][]string{}
}
- for k, v := range p.Internal.Embed {
- testEmbed[k] = v
- }
+ maps.Copy(testEmbed, p.Internal.Embed)
ptest.Internal.Embed = testEmbed
ptest.EmbedFiles = str.StringList(p.EmbedFiles, p.TestEmbedFiles)
ptest.Internal.OrigImportPath = p.Internal.OrigImportPath