cmd/gc: rewrite argtype to substitute in a single pass
Substituting in multiple passes meant walking the type
multiple times, and worse, if a complex type was substituted
in an early pass, later passes would follow it, possibly recursively,
until hitting the depth 10 limit.
Change-Id: Ie61d6ec08438e297baabe932afe33d08f358e55f
Reviewed-on: https://go-review.googlesource.com/7625
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/src/cmd/internal/gc/range.go b/src/cmd/internal/gc/range.go
index ca901d2..979c76a 100644
--- a/src/cmd/internal/gc/range.go
+++ b/src/cmd/internal/gc/range.go
@@ -311,14 +311,12 @@
fn := syslook("mapiterinit", 1)
- argtype(fn, t.Down)
- argtype(fn, t.Type)
- argtype(fn, th)
+ substArgTypes(fn, t.Down, t.Type, th)
init = list(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil)))
n.Ntest = Nod(ONE, Nod(ODOT, hit, keyname), nodnil())
fn = syslook("mapiternext", 1)
- argtype(fn, th)
+ substArgTypes(fn, th)
n.Nincr = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil))
key := Nod(ODOT, hit, keyname)