mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
16e2e95dd9
commit
80e5b52566
3 changed files with 105 additions and 121 deletions
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue