From: Matthew Dempsky Date: Fri, 4 Mar 2016 09:30:31 +0000 (-0800) Subject: cmd/compile: replace TypeList with []*Type X-Git-Tag: go1.7beta1~1562 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1765863e577634e5e0502f7a783979a5fd480618;p=gostls13.git cmd/compile: replace TypeList with []*Type Good riddance to another one-off linked list type. Change-Id: Idf9926a701ab4da8a022be1d61f1257020d58fc5 Reviewed-on: https://go-review.googlesource.com/20212 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Dave Cheney Reviewed-by: David Crawshaw --- diff --git a/src/cmd/compile/internal/gc/align.go b/src/cmd/compile/internal/gc/align.go index e5d7e6b93e..e8d84469c2 100644 --- a/src/cmd/compile/internal/gc/align.go +++ b/src/cmd/compile/internal/gc/align.go @@ -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