]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: use slice instead of linked list for nodes to export
authorRobert Griesemer <gri@golang.org>
Wed, 12 Aug 2015 21:29:50 +0000 (14:29 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 28 Aug 2015 22:49:15 +0000 (22:49 +0000)
Change-Id: Ib79ab787fdc90a5a29b25474d91afa9bfaf51276
Reviewed-on: https://go-review.googlesource.com/13589
Reviewed-by: Minux Ma <minux@golang.org>
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/go.go

index 66ae8816c344245064121cc680b9dd435f39605b..234af6cc319d7c7dc730b523d61ae3ac952a2903 100644 (file)
@@ -31,7 +31,7 @@ func exportsym(n *Node) {
        if Debug['E'] != 0 {
                fmt.Printf("export symbol %v\n", n.Sym)
        }
-       exportlist = list(exportlist, n)
+       exportlist = append(exportlist, n)
 }
 
 func exportname(s string) bool {
@@ -124,7 +124,7 @@ func reexportdep(n *Node) {
                                if Debug['E'] != 0 {
                                        fmt.Printf("reexport name %v\n", n.Sym)
                                }
-                               exportlist = list(exportlist, n)
+                               exportlist = append(exportlist, n)
                        }
                }
 
@@ -140,7 +140,7 @@ func reexportdep(n *Node) {
                                if Debug['E'] != 0 {
                                        fmt.Printf("reexport type %v from declaration\n", t.Sym)
                                }
-                               exportlist = list(exportlist, t.Sym.Def)
+                               exportlist = append(exportlist, t.Sym.Def)
                        }
                }
 
@@ -154,7 +154,7 @@ func reexportdep(n *Node) {
                                if Debug['E'] != 0 {
                                        fmt.Printf("reexport literal type %v\n", t.Sym)
                                }
-                               exportlist = list(exportlist, t.Sym.Def)
+                               exportlist = append(exportlist, t.Sym.Def)
                        }
                }
                fallthrough
@@ -164,7 +164,7 @@ func reexportdep(n *Node) {
                        if Debug['E'] != 0 {
                                fmt.Printf("reexport literal/type %v\n", n.Sym)
                        }
-                       exportlist = list(exportlist, n)
+                       exportlist = append(exportlist, n)
                }
 
                // for operations that need a type when rendered, put the type on the export list.
@@ -193,7 +193,7 @@ func reexportdep(n *Node) {
                        if Debug['E'] != 0 {
                                fmt.Printf("reexport type for expression %v\n", t.Sym)
                        }
-                       exportlist = list(exportlist, t.Sym.Def)
+                       exportlist = append(exportlist, t.Sym.Def)
                }
        }
 
@@ -376,9 +376,12 @@ func dumpexport() {
                }
        }
 
-       for l := exportlist; l != nil; l = l.Next {
-               lineno = l.N.Lineno
-               dumpsym(l.N.Sym)
+       // exportlist grows during iteration - cannot use range
+       for len(exportlist) > 0 {
+               n := exportlist[0]
+               exportlist = exportlist[1:]
+               lineno = n.Lineno
+               dumpsym(n.Sym)
        }
 
        fmt.Fprintf(bout, "\n$$\n")
index 9874ff7b6070cf831da4b42912d993aa03dd70d6..be56b817257c17d31929e623ae1ca8bebce1ceba 100644 (file)
@@ -586,7 +586,7 @@ var xtop *NodeList
 
 var externdcl *NodeList
 
-var exportlist *NodeList
+var exportlist []*Node
 
 var importlist *NodeList // imported functions and methods with inlinable bodies