From 27a70ea560bc21559aa180dd3ea5298d0732b5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 11 Sep 2017 21:23:44 +0200 Subject: [PATCH] cmd/compile: simplify a few early var declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These were likely written in C or added by an automated tool. Either way, they're unnecessary now. Clean up the code. Change-Id: I56de2c7bb60ebab8c500803a8b6586bdf4bf75c7 Reviewed-on: https://go-review.googlesource.com/62951 Run-TryBot: Daniel Martí Reviewed-by: Dave Cheney TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/walk.go | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index b23cb56f105..157693f3210 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -113,15 +113,12 @@ func paramoutheap(fn *Node) bool { // adds "adjust" to all the argument locations for the call n. // n must be a defer or go node that has already been walked. func adjustargs(n *Node, adjust int) { - var arg *Node - var lhs *Node - callfunc := n.Left - for _, arg = range callfunc.List.Slice() { + for _, arg := range callfunc.List.Slice() { if arg.Op != OAS { Fatalf("call arg not assignment") } - lhs = arg.Left + lhs := arg.Left if lhs.Op == ONAME { // This is a temporary introduced by reorder1. // The real store to the stack appears later in the arg list. @@ -303,9 +300,8 @@ func walkstmt(n *Node) *Node { // so that reorder3 can fix up conflicts var rl []*Node - var cl Class for _, ln := range Curfn.Func.Dcl { - cl = ln.Class() + cl := ln.Class() if cl == PAUTO || cl == PAUTOHEAP { break } @@ -2367,7 +2363,6 @@ func reorder1(all []*Node) []*Node { var f *Node // last fncall assigned to stack var r []*Node // non fncalls and tempnames assigned to stack d := 0 - var a *Node for _, n := range all { if !n.HasCall() { r = append(r, n) @@ -2381,7 +2376,7 @@ func reorder1(all []*Node) []*Node { } // make assignment of fncall to tempname - a = temp(n.Right.Type) + a := temp(n.Right.Type) a = nod(OAS, a, n.Right) g = append(g, a) @@ -2406,8 +2401,6 @@ func reorder1(all []*Node) []*Node { // // function calls have been removed. func reorder3(all []*Node) []*Node { - var l *Node - // If a needed expression may be affected by an // earlier assignment, make an early copy of that // expression and use the copy instead. @@ -2415,7 +2408,7 @@ func reorder3(all []*Node) []*Node { var mapinit Nodes for i, n := range all { - l = n.Left + l := n.Left // Save subexpressions needed on left side. // Drill through non-dereferences. @@ -2522,9 +2515,8 @@ func aliased(n *Node, all []*Node, i int) bool { memwrite := 0 varwrite := 0 - var a *Node for _, an := range all[:i] { - a = outervalue(an.Left) + a := outervalue(an.Left) for a.Op == ODOT { a = a.Left @@ -3915,12 +3907,10 @@ func walkprintfunc(n *Node, init *Nodes) *Node { t := nod(OTFUNC, nil, nil) num := 0 var printargs []*Node - var a *Node - var buf string for _, n1 := range n.List.Slice() { - buf = fmt.Sprintf("a%d", num) + buf := fmt.Sprintf("a%d", num) num++ - a = namedfield(buf, n1.Type) + a := namedfield(buf, n1.Type) t.List.Append(a) printargs = append(printargs, a.Left) } @@ -3932,7 +3922,7 @@ func walkprintfunc(n *Node, init *Nodes) *Node { sym := lookupN("print·%d", walkprintfunc_prgen) fn := dclfunc(sym, t) - a = nod(n.Op, nil, nil) + a := nod(n.Op, nil, nil) a.List.Set(printargs) a = typecheck(a, Etop) a = walkstmt(a)