mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove NodeList type
That was easy. Fixes #14473. Change-Id: I9d1d20a5c5a9b1423e6c72c0460ee4a78130864f Reviewed-on: https://go-review.googlesource.com/20521 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
1d809c5c14
commit
72655afb4e
5 changed files with 21 additions and 114 deletions
|
|
@ -360,60 +360,6 @@ const (
|
|||
OEND
|
||||
)
|
||||
|
||||
// A NodeList is a linked list of nodes.
|
||||
// TODO(rsc): Some uses of NodeList should be made into slices.
|
||||
// The remaining ones probably just need a simple linked list,
|
||||
// not one with concatenation support.
|
||||
type NodeList struct {
|
||||
N *Node
|
||||
Next *NodeList
|
||||
End *NodeList
|
||||
}
|
||||
|
||||
// concat returns the concatenation of the lists a and b.
|
||||
// The storage taken by both is reused for the result.
|
||||
func concat(a *NodeList, b *NodeList) *NodeList {
|
||||
if a == nil {
|
||||
return b
|
||||
}
|
||||
if b == nil {
|
||||
return a
|
||||
}
|
||||
|
||||
a.End.Next = b
|
||||
a.End = b.End
|
||||
b.End = nil
|
||||
return a
|
||||
}
|
||||
|
||||
// list1 returns a one-element list containing n.
|
||||
func list1(n *Node) *NodeList {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
l := new(NodeList)
|
||||
l.N = n
|
||||
l.End = l
|
||||
return l
|
||||
}
|
||||
|
||||
// list returns the result of appending n to l.
|
||||
func list(l *NodeList, n *Node) *NodeList {
|
||||
return concat(l, list1(n))
|
||||
}
|
||||
|
||||
// count returns the length of the list l.
|
||||
func count(l *NodeList) int {
|
||||
n := int64(0)
|
||||
for ; l != nil; l = l.Next {
|
||||
n++
|
||||
}
|
||||
if int64(int(n)) != n { // Overflow.
|
||||
Yyerror("too many elements in list")
|
||||
}
|
||||
return int(n)
|
||||
}
|
||||
|
||||
// Nodes is a pointer to a slice of *Node.
|
||||
// For fields that are not used in most nodes, this is used instead of
|
||||
// a slice to save space.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue