mirror of
https://github.com/golang/go.git
synced 2025-05-30 03:41:33 +00: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:
parent
a81283d5d9
commit
6c4e90a99e
@ -489,10 +489,10 @@ func colas(left *NodeList, right *NodeList, lno int32) *Node {
|
|||||||
setNodeSeq(&as.Rlist, right)
|
setNodeSeq(&as.Rlist, right)
|
||||||
as.Colas = true
|
as.Colas = true
|
||||||
as.Lineno = lno
|
as.Lineno = lno
|
||||||
colasdefn(left, as)
|
colasdefn(as.List, as)
|
||||||
|
|
||||||
// make the tree prettier; not necessary
|
// 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.Left = nodeSeqFirst(as.List)
|
||||||
as.Right = nodeSeqFirst(as.Rlist)
|
as.Right = nodeSeqFirst(as.Rlist)
|
||||||
setNodeSeq(&as.List, nil)
|
setNodeSeq(&as.List, nil)
|
||||||
|
@ -633,7 +633,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
|||||||
r := Nod(ORANGE, nil, p.expr())
|
r := Nod(ORANGE, nil, p.expr())
|
||||||
setNodeSeq(&r.List, lhs)
|
setNodeSeq(&r.List, lhs)
|
||||||
r.Colas = true
|
r.Colas = true
|
||||||
colasdefn(lhs, r)
|
colasdefn(r.List, r)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,9 +685,9 @@ func (p *parser) labeled_stmt(label *Node) *Node {
|
|||||||
l := list1(label)
|
l := list1(label)
|
||||||
if ls != nil {
|
if ls != nil {
|
||||||
if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 {
|
if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 {
|
||||||
l = concat(l, ls.List)
|
appendNodeSeq(&l, ls.List)
|
||||||
} else {
|
} else {
|
||||||
l = list(l, ls)
|
appendNodeSeqNode(&l, ls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return liststmt(l)
|
return liststmt(l)
|
||||||
@ -1021,7 +1021,9 @@ func (p *parser) if_header() *Node {
|
|||||||
|
|
||||||
init, cond, _ := p.header(false)
|
init, cond, _ := p.header(false)
|
||||||
h := Nod(OIF, nil, nil)
|
h := Nod(OIF, nil, nil)
|
||||||
setNodeSeq(&h.Ninit, []*Node{init})
|
if init != nil {
|
||||||
|
setNodeSeq(&h.Ninit, []*Node{init})
|
||||||
|
}
|
||||||
h.Left = cond
|
h.Left = cond
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
@ -1048,7 +1050,7 @@ func (p *parser) if_stmt() *Node {
|
|||||||
setNodeSeq(&stmt.Rlist, []*Node{p.if_stmt()})
|
setNodeSeq(&stmt.Rlist, []*Node{p.if_stmt()})
|
||||||
} else {
|
} else {
|
||||||
cs := p.compound_stmt(true)
|
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)
|
setNodeSeq(&stmt.Rlist, cs.List)
|
||||||
} else {
|
} else {
|
||||||
setNodeSeq(&stmt.Rlist, []*Node{cs})
|
setNodeSeq(&stmt.Rlist, []*Node{cs})
|
||||||
@ -2548,9 +2550,9 @@ func (p *parser) stmt_list() (l *NodeList) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if s != nil && s.Op == OBLOCK && nodeSeqLen(s.Ninit) == 0 {
|
if s != nil && s.Op == OBLOCK && nodeSeqLen(s.Ninit) == 0 {
|
||||||
l = concat(l, s.List)
|
appendNodeSeq(&l, s.List)
|
||||||
} else {
|
} else {
|
||||||
l = list(l, s)
|
appendNodeSeqNode(&l, s)
|
||||||
}
|
}
|
||||||
// customized version of osemi:
|
// customized version of osemi:
|
||||||
// ';' is optional before a closing ')' or '}'
|
// ';' is optional before a closing ')' or '}'
|
||||||
|
@ -15,10 +15,10 @@ type Node struct {
|
|||||||
// Generic recursive walks should follow these fields.
|
// Generic recursive walks should follow these fields.
|
||||||
Left *Node
|
Left *Node
|
||||||
Right *Node
|
Right *Node
|
||||||
Ninit *NodeList
|
Ninit Nodes
|
||||||
Nbody Nodes
|
Nbody Nodes
|
||||||
List *NodeList
|
List Nodes
|
||||||
Rlist *NodeList
|
Rlist Nodes
|
||||||
|
|
||||||
// most nodes
|
// most nodes
|
||||||
Type *Type
|
Type *Type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user