1
0
mirror of https://github.com/golang/go synced 2024-11-12 10:00:25 -07:00

cmd/compile: change Node fields from *NodeList to Nodes

Compile time is about the same.  Getting rid of the nodeSeq interfaces,
particularly nodeSeqIterate, should produce some improvements.

Passes toolstash -cmp.

Update #14473.

Change-Id: I678abafdd9129c6cccb0ec980511932eaed496a0
Reviewed-on: https://go-review.googlesource.com/20343
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Ian Lance Taylor 2016-03-07 14:32:18 -08:00
parent a81283d5d9
commit 6c4e90a99e
3 changed files with 14 additions and 12 deletions

View File

@ -489,10 +489,10 @@ func colas(left *NodeList, right *NodeList, lno int32) *Node {
setNodeSeq(&as.Rlist, right)
as.Colas = true
as.Lineno = lno
colasdefn(left, as)
colasdefn(as.List, as)
// make the tree prettier; not necessary
if count(left) == 1 && count(right) == 1 {
if nodeSeqLen(as.List) == 1 && nodeSeqLen(as.Rlist) == 1 {
as.Left = nodeSeqFirst(as.List)
as.Right = nodeSeqFirst(as.Rlist)
setNodeSeq(&as.List, nil)

View File

@ -633,7 +633,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
r := Nod(ORANGE, nil, p.expr())
setNodeSeq(&r.List, lhs)
r.Colas = true
colasdefn(lhs, r)
colasdefn(r.List, r)
return r
}
@ -685,9 +685,9 @@ func (p *parser) labeled_stmt(label *Node) *Node {
l := list1(label)
if ls != nil {
if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 {
l = concat(l, ls.List)
appendNodeSeq(&l, ls.List)
} else {
l = list(l, ls)
appendNodeSeqNode(&l, ls)
}
}
return liststmt(l)
@ -1021,7 +1021,9 @@ func (p *parser) if_header() *Node {
init, cond, _ := p.header(false)
h := Nod(OIF, nil, nil)
setNodeSeq(&h.Ninit, []*Node{init})
if init != nil {
setNodeSeq(&h.Ninit, []*Node{init})
}
h.Left = cond
return h
}
@ -1048,7 +1050,7 @@ func (p *parser) if_stmt() *Node {
setNodeSeq(&stmt.Rlist, []*Node{p.if_stmt()})
} else {
cs := p.compound_stmt(true)
if cs.Op == OBLOCK && cs.Ninit == nil {
if cs.Op == OBLOCK && nodeSeqLen(cs.Ninit) == 0 {
setNodeSeq(&stmt.Rlist, cs.List)
} else {
setNodeSeq(&stmt.Rlist, []*Node{cs})
@ -2548,9 +2550,9 @@ func (p *parser) stmt_list() (l *NodeList) {
break
}
if s != nil && s.Op == OBLOCK && nodeSeqLen(s.Ninit) == 0 {
l = concat(l, s.List)
appendNodeSeq(&l, s.List)
} else {
l = list(l, s)
appendNodeSeqNode(&l, s)
}
// customized version of osemi:
// ';' is optional before a closing ')' or '}'

View File

@ -15,10 +15,10 @@ type Node struct {
// Generic recursive walks should follow these fields.
Left *Node
Right *Node
Ninit *NodeList
Ninit Nodes
Nbody Nodes
List *NodeList
Rlist *NodeList
List Nodes
Rlist Nodes
// most nodes
Type *Type