cmd/compile: inline list storage stealing

It is only necessary in a few places, and this inlining will
simplify the transition away from NodeLists.

Passes toolstash -cmp.

Change-Id: I4ee9b4bf56ffa04df23e20a0a83b302d36b33510
Reviewed-on: https://go-review.googlesource.com/20290
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-03-05 16:25:58 -08:00
parent b8a2e25f55
commit a81283d5d9
2 changed files with 16 additions and 30 deletions

View file

@ -391,15 +391,6 @@ func list1(n *Node) *NodeList {
if n == nil {
return nil
}
if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
// Flatten list and steal storage.
// Poison pointer to catch errant uses.
l := n.List
setNodeSeq(&n.List, nil)
return l
}
l := new(NodeList)
l.N = n
l.End = l
@ -741,15 +732,6 @@ func setNodeSeq(a nodesOrNodeListPtr, b nodesOrNodeList) {
// This is an interim function during the transition from NodeList to Nodes.
// TODO(iant): Remove when transition is complete.
func setNodeSeqNode(a nodesOrNodeListPtr, n *Node) {
// This is what the old list1 function did;
// the rest of the compiler has come to expect it.
if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
l := n.List
setNodeSeq(&n.List, nil)
setNodeSeq(a, l)
return
}
switch a := a.(type) {
case **NodeList:
*a = list1(n)
@ -822,15 +804,6 @@ func appendNodeSeq(a nodesOrNodeListPtr, b nodesOrNodeList) {
// This is an interim function during the transition from NodeList to Nodes.
// TODO(iant): Remove when transition is complete.
func appendNodeSeqNode(a nodesOrNodeListPtr, n *Node) {
// This is what the old list1 function did;
// the rest of the compiler has come to expect it.
if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
l := n.List
setNodeSeq(&n.List, nil)
appendNodeSeq(a, l)
return
}
switch a := a.(type) {
case **NodeList:
*a = list(*a, n)