From d6e80069f3007d5bc03750f0a83e213bbac8c86e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6hrmann?= Date: Sun, 21 Jan 2018 13:02:27 +0100 Subject: [PATCH] cmd/compile: simplify as2 method of *Order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge the two for loops that set up the node lists for temporaries into one for loop. Passes toolstash -cmp Change-Id: Ibc739115f38c8869b0dcfbf9819fdc2fc96962e0 Reviewed-on: https://go-review.googlesource.com/c/141819 Reviewed-by: Keith Randall Run-TryBot: Martin Möhrmann TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/order.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go index 519fad4b7ed..f33689298f3 100644 --- a/src/cmd/compile/internal/gc/order.go +++ b/src/cmd/compile/internal/gc/order.go @@ -1253,9 +1253,10 @@ func okas(ok, val *Node) *Node { func (o *Order) as2(n *Node) { tmplist := []*Node{} left := []*Node{} - for _, l := range n.List.Slice() { + for ni, l := range n.List.Slice() { if !l.isBlank() { tmp := o.newTemp(l.Type, types.Haspointers(l.Type)) + n.List.SetIndex(ni, tmp) tmplist = append(tmplist, tmp) left = append(left, l) } @@ -1268,14 +1269,6 @@ func (o *Order) as2(n *Node) { as.Rlist.Set(tmplist) as = typecheck(as, Etop) o.stmt(as) - - ti := 0 - for ni, l := range n.List.Slice() { - if !l.isBlank() { - n.List.SetIndex(ni, tmplist[ti]) - ti++ - } - } } // okAs2 orders OAS2 with ok.