]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: replace TypeList with []*Type
authorMatthew Dempsky <mdempsky@google.com>
Fri, 4 Mar 2016 09:30:31 +0000 (01:30 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 4 Mar 2016 14:30:35 +0000 (14:30 +0000)
Good riddance to another one-off linked list type.

Change-Id: Idf9926a701ab4da8a022be1d61f1257020d58fc5
Reviewed-on: https://go-review.googlesource.com/20212
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/compile/internal/gc/align.go

index e5d7e6b93efd8efab64e09979ab9d506bb041a6f..e8d84469c23cdc26bd6b87089981d5cc8167a990 100644 (file)
@@ -341,14 +341,8 @@ func dowidth(t *Type) {
 // dowidth should only be called when the type's size
 // is needed immediately.  checkwidth makes sure the
 // size is evaluated eventually.
-type TypeList struct {
-       t    *Type
-       next *TypeList
-}
-
-var tlfree *TypeList
 
-var tlq *TypeList
+var deferredTypeStack []*Type
 
 func checkwidth(t *Type) {
        if t == nil {
@@ -371,16 +365,7 @@ func checkwidth(t *Type) {
        }
        t.Deferwidth = true
 
-       l := tlfree
-       if l != nil {
-               tlfree = l.next
-       } else {
-               l = new(TypeList)
-       }
-
-       l.t = t
-       l.next = tlq
-       tlq = l
+       deferredTypeStack = append(deferredTypeStack, t)
 }
 
 func defercheckwidth() {
@@ -395,12 +380,11 @@ func resumecheckwidth() {
        if defercalc == 0 {
                Fatalf("resumecheckwidth")
        }
-       for l := tlq; l != nil; l = tlq {
-               l.t.Deferwidth = false
-               tlq = l.next
-               dowidth(l.t)
-               l.next = tlfree
-               tlfree = l
+       for len(deferredTypeStack) > 0 {
+               t := deferredTypeStack[len(deferredTypeStack)-1]
+               deferredTypeStack = deferredTypeStack[:len(deferredTypeStack)-1]
+               t.Deferwidth = false
+               dowidth(t)
        }
 
        defercalc = 0