]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: initialize importMap lazily
authorRuss Cox <rsc@golang.org>
Thu, 19 Nov 2020 22:16:50 +0000 (17:16 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 24 Nov 2020 14:58:20 +0000 (14:58 +0000)
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 <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/main.go

index 61742fc8ce72116468015495cea544d0a73904e4..d1b4161277ef9d0f46a4e8e4c240e3583512c240 100644 (file)
@@ -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 {