mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add Nodes.Prepend helper method
Prepared with gofmt -r. Change-Id: Ib9f224cc20353acd9c5850dead1a2d32ca5427d3 Reviewed-on: https://go-review.googlesource.com/29165 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
6f135bfd92
commit
4b8a1611b5
9 changed files with 30 additions and 16 deletions
|
|
@ -583,15 +583,29 @@ func (n Nodes) Addr(i int) **Node {
|
|||
// Append appends entries to Nodes.
|
||||
// If a slice is passed in, this will take ownership of it.
|
||||
func (n *Nodes) Append(a ...*Node) {
|
||||
if len(a) == 0 {
|
||||
return
|
||||
}
|
||||
if n.slice == nil {
|
||||
if len(a) > 0 {
|
||||
n.slice = &a
|
||||
}
|
||||
n.slice = &a
|
||||
} else {
|
||||
*n.slice = append(*n.slice, a...)
|
||||
}
|
||||
}
|
||||
|
||||
// Prepend prepends entries to Nodes.
|
||||
// If a slice is passed in, this will take ownership of it.
|
||||
func (n *Nodes) Prepend(a ...*Node) {
|
||||
if len(a) == 0 {
|
||||
return
|
||||
}
|
||||
if n.slice == nil {
|
||||
n.slice = &a
|
||||
} else {
|
||||
*n.slice = append(a, *n.slice...)
|
||||
}
|
||||
}
|
||||
|
||||
// AppendNodes appends the contents of *n2 to n, then clears n2.
|
||||
func (n *Nodes) AppendNodes(n2 *Nodes) {
|
||||
switch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue