aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2016-02-28 14:39:38 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2016-02-29 02:17:58 +0000
commit1b417e20ffe052d51835ec84dcc5df08717cb8a3 (patch)
tree08f8e7ce9347ec5e311e3f80e97668d41b06a484
parent1d5001afef65bdb48db751f474efab624b14c362 (diff)
downloadgo-1b417e20ffe052d51835ec84dcc5df08717cb8a3.tar.xz
cmd/compile: superficial cleanup in maplit
Mostly renaming variables for clarity. Passes toolstash -cmp. Change-Id: I9867137c34c14985cbbbdb2d34fbbe4cc65cb6fb Reviewed-on: https://go-review.googlesource.com/20023 Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/sinit.go42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go
index c6647cc7f5..12bdfbada5 100644
--- a/src/cmd/compile/internal/gc/sinit.go
+++ b/src/cmd/compile/internal/gc/sinit.go
@@ -868,8 +868,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init **NodeList) {
litas(var_, a, init)
// count the initializers
- b := int64(0)
-
+ b := 0
for l := n.List; l != nil; l = l.Next {
r := l.N
if r.Op != OKEY {
@@ -886,35 +885,32 @@ func maplit(ctxt int, n *Node, var_ *Node, init **NodeList) {
if b != 0 {
// build type [count]struct { a Tindex, b Tvalue }
t := n.Type
-
tk := t.Down
tv := t.Type
symb := Lookup("b")
- t = typ(TFIELD)
- t.Type = tv
- t.Sym = symb
+ fieldb := typ(TFIELD)
+ fieldb.Type = tv
+ fieldb.Sym = symb
syma := Lookup("a")
- t1 := t
- t = typ(TFIELD)
- t.Type = tk
- t.Sym = syma
- t.Down = t1
+ fielda := typ(TFIELD)
+ fielda.Type = tk
+ fielda.Sym = syma
+ fielda.Down = fieldb
- t1 = t
- t = typ(TSTRUCT)
- t.Type = t1
+ tstruct := typ(TSTRUCT)
+ tstruct.Type = fielda
- t1 = t
- t = typ(TARRAY)
- t.Bound = b
- t.Type = t1
+ tarr := typ(TARRAY)
+ tarr.Bound = int64(b)
+ tarr.Type = tstruct
- dowidth(t)
+ // TODO(josharian): suppress alg generation for these types?
+ dowidth(tarr)
// make and initialize static array
- vstat := staticname(t, ctxt)
+ vstat := staticname(tarr, ctxt)
b := int64(0)
for l := n.List; l != nil; l = l.Next {
@@ -976,7 +972,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init **NodeList) {
a.Nbody.Set([]*Node{r})
a.Ninit = list1(Nod(OAS, index, Nodintconst(0)))
- a.Left = Nod(OLT, index, Nodintconst(t.Bound))
+ a.Left = Nod(OLT, index, Nodintconst(tarr.Bound))
a.Right = Nod(OAS, index, Nod(OADD, index, Nodintconst(1)))
typecheck(&a, Etop)
@@ -985,9 +981,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init **NodeList) {
}
// put in dynamic entries one-at-a-time
- var key *Node
-
- var val *Node
+ var key, val *Node
for l := n.List; l != nil; l = l.Next {
r := l.N