mirror of
https://github.com/golang/go.git
synced 2025-05-30 19:52:53 +00:00
cmd/link/internal/loadpe: allocate comdat definitions map lazily
Switch the "comdatDefinitions" map to lazy allocation; we only need it for loading PE objects, no point doing an allocation during package init if we don't need it. Change-Id: Ie33f2c56e964f35ac2e137840ac021cfaaa897c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/540255 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
This commit is contained in:
parent
36f3ec5912
commit
17211b64b6
@ -219,7 +219,7 @@ type peLoaderState struct {
|
|||||||
// comdatDefinitions records the names of symbols for which we've
|
// comdatDefinitions records the names of symbols for which we've
|
||||||
// previously seen a definition in COMDAT. Key is symbol name, value
|
// previously seen a definition in COMDAT. Key is symbol name, value
|
||||||
// is symbol size (or -1 if we're using the "any" strategy).
|
// is symbol size (or -1 if we're using the "any" strategy).
|
||||||
var comdatDefinitions = make(map[string]int64)
|
var comdatDefinitions map[string]int64
|
||||||
|
|
||||||
// Load loads the PE file pn from input.
|
// Load loads the PE file pn from input.
|
||||||
// Symbols from the object file are created via the loader 'l',
|
// Symbols from the object file are created via the loader 'l',
|
||||||
@ -236,6 +236,9 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
|
|||||||
pn: pn,
|
pn: pn,
|
||||||
}
|
}
|
||||||
createImportSymsState(state.l, state.arch)
|
createImportSymsState(state.l, state.arch)
|
||||||
|
if comdatDefinitions == nil {
|
||||||
|
comdatDefinitions = make(map[string]int64)
|
||||||
|
}
|
||||||
|
|
||||||
// Some input files are archives containing multiple of
|
// Some input files are archives containing multiple of
|
||||||
// object files, and pe.NewFile seeks to the start of
|
// object files, and pe.NewFile seeks to the start of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user