Commit 3366f515 authored by Daniel Martí's avatar Daniel Martí

cmd/compile: tweaks to unindent some code

Prioritized the chunks of code with 8 or more levels of indentation.
Basically early breaks/returns and joining nested ifs.

Change-Id: I6817df1303226acf2eb904a29f2db720e4f7427a
Reviewed-on: https://go-review.googlesource.com/55630
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 064ae118
......@@ -463,9 +463,8 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
Warnl(func_.Pos, "closure converted to global")
}
return func_.Func.Closure.Func.Nname
} else {
closuredebugruntimecheck(func_)
}
closuredebugruntimecheck(func_)
// Create closure in the form of a composite literal.
// supposing the closure captures an int i and a string s
......
......@@ -1554,7 +1554,10 @@ func (e *EscState) esccall(call *Node, parent *Node) {
call.Right = arg
}
e.escassignWhyWhere(n, arg, "arg to recursive call", call) // TODO this message needs help.
if arg != args[0] {
if arg == args[0] {
args = args[1:]
continue
}
// "..." arguments are untracked
for _, a := range args {
if Debug['m'] > 3 {
......@@ -1565,9 +1568,6 @@ func (e *EscState) esccall(call *Node, parent *Node) {
// No more PPARAM processing, but keep
// going for PPARAMOUT.
args = nil
continue
}
args = args[1:]
case PPARAMOUT:
cE.Retval.Append(n)
......
......@@ -233,7 +233,9 @@ func (s *phiState) insertVarPhis(n int, var_ *Node, defs []*ssa.Block, typ *type
// a D-edge, or an edge whose target is in currentRoot's subtree.
continue
}
if !hasPhi.contains(c.ID) {
if hasPhi.contains(c.ID) {
continue
}
// Add a phi to block c for variable n.
hasPhi.add(c.ID)
v := c.NewValue0I(currentRoot.Pos, ssa.OpPhi, typ, int64(n)) // TODO: line number right?
......@@ -252,7 +254,6 @@ func (s *phiState) insertVarPhis(n int, var_ *Node, defs []*ssa.Block, typ *type
hasDef.add(c.ID)
}
}
}
// Visit children if they have not been visited yet.
for c := s.tree[b.ID].firstChild; c != nil; c = s.tree[c.ID].sibling {
......
......@@ -497,14 +497,12 @@ func dgopkgpathOff(s *obj.LSym, ot int, pkg *types.Pkg) int {
func isExportedField(ft *types.Field) (bool, *types.Pkg) {
if ft.Sym != nil && ft.Embedded == 0 {
return exportname(ft.Sym.Name), ft.Sym.Pkg
} else {
}
if ft.Type.Sym != nil &&
(ft.Type.Sym.Pkg == builtinpkg || !exportname(ft.Type.Sym.Name)) {
return false, ft.Type.Sym.Pkg
} else {
return true, nil
}
}
return true, nil
}
// dnameField dumps a reflect.name for a struct field.
......
......@@ -480,9 +480,8 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
n := *l
gdata(&n, r.Func.Closure.Func.Nname, Widthptr)
return true
} else {
closuredebugruntimecheck(r)
}
closuredebugruntimecheck(r)
case OCONVIFACE:
// This logic is mirrored in isStaticCompositeLiteral.
......
......@@ -661,24 +661,26 @@ func (s *state) stmt(n *Node) {
}
rhs = nil
case OAPPEND:
// If we're writing the result of an append back to the same slice,
// handle it specially to avoid write barriers on the fast (non-growth) path.
// Check whether we're writing the result of an append back to the same slice.
// If so, we handle it specially to avoid write barriers on the fast
// (non-growth) path.
if !samesafeexpr(n.Left, rhs.List.First()) {
break
}
// If the slice can be SSA'd, it'll be on the stack,
// so there will be no write barriers,
// so there's no need to attempt to prevent them.
if samesafeexpr(n.Left, rhs.List.First()) {
if !s.canSSA(n.Left) {
if Debug_append > 0 {
Warnl(n.Pos, "append: len-only update")
}
s.append(rhs, true)
return
} else {
if s.canSSA(n.Left) {
if Debug_append > 0 { // replicating old diagnostic message
Warnl(n.Pos, "append: len-only update (in local slice)")
}
break
}
if Debug_append > 0 {
Warnl(n.Pos, "append: len-only update")
}
s.append(rhs, true)
return
}
}
......
......@@ -2636,8 +2636,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *types.Type, nl Nodes,
n = nil
if nl.Len() == 1 {
n = nl.First()
if n.Type != nil {
if n.Type.IsFuncArgStruct() {
if n.Type != nil && n.Type.IsFuncArgStruct() {
if !hasddd(tstruct) {
n1 := tstruct.NumFields()
n2 := n.Type.NumFields()
......@@ -2685,7 +2684,6 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *types.Type, nl Nodes,
goto out
}
}
}
n1 = tstruct.NumFields()
n2 = nl.Len()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment