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>
// 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 {
}
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() {
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