cmd/compile: early return/continue to unindent some code

While at it, also simplify a couple of switches.

Doesn't pass toolstash -cmp on std cmd, because orderBlock(&n2.Nbody) is
moved further down to the n3 loop.

Change-Id: I20a2a6c21eb9a183a59572e0fca401a5041fc40a
Reviewed-on: https://go-review.googlesource.com/104416
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Daniel Martí 2018-04-03 13:17:28 +01:00
parent 9767727353
commit fcfea24742
3 changed files with 163 additions and 164 deletions

View file

@ -347,20 +347,21 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
n.Type = e.Expr.Type
if e.Expr.Op == OLITERAL {
gdata(n, e.Expr, int(n.Type.Width))
} else {
ll := n.copy()
ll.Orig = ll // completely separate copy
if !staticassign(ll, e.Expr, out) {
// Requires computation, but we're
// copying someone else's computation.
rr := orig.copy()
rr.Orig = rr // completely separate copy
rr.Type = ll.Type
rr.Xoffset += e.Xoffset
setlineno(rr)
*out = append(*out, nod(OAS, ll, rr))
}
continue
}
ll := n.copy()
ll.Orig = ll // completely separate copy
if staticassign(ll, e.Expr, out) {
continue
}
// Requires computation, but we're
// copying someone else's computation.
rr := orig.copy()
rr.Orig = rr // completely separate copy
rr.Type = ll.Type
rr.Xoffset += e.Xoffset
setlineno(rr)
*out = append(*out, nod(OAS, ll, rr))
}
return true
@ -449,13 +450,13 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
n.Type = e.Expr.Type
if e.Expr.Op == OLITERAL {
gdata(n, e.Expr, int(n.Type.Width))
} else {
setlineno(e.Expr)
a := n.copy()
a.Orig = a // completely separate copy
if !staticassign(a, e.Expr, out) {
*out = append(*out, nod(OAS, a, e.Expr))
}
continue
}
setlineno(e.Expr)
a := n.copy()
a.Orig = a // completely separate copy
if !staticassign(a, e.Expr, out) {
*out = append(*out, nod(OAS, a, e.Expr))
}
}