cmd/compile: change order.go to use nodeSeq

Passes toolstash -cmp

Update #14473.

Change-Id: I15b35d40a5ec1f4355ee38bc6d131920933ac95c
Reviewed-on: https://go-review.googlesource.com/20237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2016-03-04 14:29:24 -08:00
parent 16e2e95dd9
commit 80e5b52566
3 changed files with 105 additions and 121 deletions

View file

@ -617,27 +617,31 @@ func nodeSeqLen(ns nodesOrNodeList) int {
}
}
// nodeSeqFirst returns the first element of either a *NodeList or a Nodes.
// It panics if the sequence is empty.
// nodeSeqFirst returns the first element of a *NodeList, a Nodes,
// or a []*Node. It panics if the sequence is empty.
func nodeSeqFirst(ns nodesOrNodeList) *Node {
switch ns := ns.(type) {
case *NodeList:
return ns.N
case Nodes:
return ns.Slice()[0]
case []*Node:
return ns[0]
default:
panic("can't happen")
}
}
// nodeSeqSecond returns the second element of either a *NodeList or a Nodes.
// It panics if the sequence has fewer than two elements.
// nodeSeqSecond returns the second element of a *NodeList, a Nodes,
// or a []*Node. It panics if the sequence has fewer than two elements.
func nodeSeqSecond(ns nodesOrNodeList) *Node {
switch ns := ns.(type) {
case *NodeList:
return ns.Next.N
case Nodes:
return ns.Slice()[1]
case []*Node:
return ns[1]
default:
panic("can't happen")
}