From 5fd949e4bd18ec2068e614c17be0a74969dc13b8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 19 Nov 2020 17:16:50 -0500 Subject: [PATCH] [dev.regabi] cmd/compile: initialize importMap lazily This sets up the next CL, moving importMap to a global zeroed struct. Change-Id: I1acc91b440d3da6e28fb32bd275fb3cd36db4e97 Reviewed-on: https://go-review.googlesource.com/c/go/+/272046 Trust: Russ Cox Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/gc/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 61742fc8ce..d1b4161277 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -877,11 +877,14 @@ func writebench(filename string) error { } var ( - importMap = map[string]string{} + importMap map[string]string packageFile map[string]string // nil means not in use ) func addImportMap(s string) { + if importMap == nil { + importMap = make(map[string]string) + } if strings.Count(s, "=") != 1 { log.Fatal("-importmap argument must be of the form source=actual") } @@ -894,6 +897,9 @@ func addImportMap(s string) { } func readImportCfg(file string) { + if importMap == nil { + importMap = make(map[string]string) + } packageFile = map[string]string{} data, err := ioutil.ReadFile(file) if err != nil { -- 2.48.1