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>
n.Left = orderexprinplace(n.Left, order)
var l []*Node
cleantempnopop(t, order, &l)
- n.Nbody.Set(append(l, n.Nbody.Slice()...))
+ n.Nbody.Prepend(l...)
orderblockNodes(&n.Nbody)
n.Right = orderstmtinplace(n.Right)
order.out = append(order.out, n)
n.Left = orderexprinplace(n.Left, order)
var l []*Node
cleantempnopop(t, order, &l)
- n.Nbody.Set(append(l, n.Nbody.Slice()...))
+ n.Nbody.Prepend(l...)
l = nil
cleantempnopop(t, order, &l)
- n.Rlist.Set(append(l, n.Rlist.Slice()...))
+ n.Rlist.Prepend(l...)
poptemp(t, order)
orderblockNodes(&n.Nbody)
n.Rlist.Set(orderblock(n.Rlist))
for _, n3 := range n.List.Slice() {
s := n3.Ninit.Slice()
cleantempnopop(t, order, &s)
- n3.Nbody.Set(append(s, n3.Nbody.Slice()...))
+ n3.Nbody.Prepend(s...)
n3.Ninit.Set(nil)
}
var s []*Node
cleantempnopop(mark, order, &s)
- n.Right.Ninit.Set(append(s, n.Right.Ninit.Slice()...))
+ n.Right.Ninit.Prepend(s...)
n.Right = orderexprinplace(n.Right, order)
case OCALLFUNC,
if t.Nname != nil {
n := Nod(OAS, t.Nname, nil)
n = typecheck(n, Etop)
- Curfn.Nbody.Set(append([]*Node{n}, Curfn.Nbody.Slice()...))
+ Curfn.Nbody.Prepend(n)
}
}
}
nodpc.Type = Types[TUINTPTR]
nodpc.Xoffset = int64(-Widthptr)
nd := mkcall("racefuncenter", nil, nil, &nodpc)
- fn.Func.Enter.Set(append([]*Node{nd}, fn.Func.Enter.Slice()...))
+ fn.Func.Enter.Prepend(nd)
nd = mkcall("racefuncexit", nil, nil)
fn.Func.Exit.Append(nd)
}
n.Left = typecheck(n.Left, Erv)
n.Right = typecheck(n.Right, Etop)
typecheckslice(body, Etop)
- n.Nbody.Set(append(body, n.Nbody.Slice()...))
+ n.Nbody.Prepend(body...)
n = walkstmt(n)
lineno = lno
}
n.Op = OAS2
- n.List.Set(append([]*Node{n.Left}, n.List.Slice()...))
+ n.List.Prepend(n.Left)
n.Rlist.Set1(n.Right)
n.Right = nil
n.Left = nil
n.Typecheck = 1
}
- n.Ninit.Set(append(init, n.Ninit.Slice()...))
+ n.Ninit.Prepend(init...)
n.Ullman = UINF
return n
}
// handle default case
if nerrors == 0 {
cas = append(cas, clauses.defjmp)
- sw.Nbody.Set(append(cas, sw.Nbody.Slice()...))
+ sw.Nbody.Prepend(cas...)
walkstmtlist(sw.Nbody.Slice())
}
}
// handle default case
if nerrors == 0 {
cas = append(cas, def)
- sw.Nbody.Set(append(cas, sw.Nbody.Slice()...))
+ sw.Nbody.Prepend(cas...)
sw.List.Set(nil)
walkstmtlist(sw.Nbody.Slice())
}
// 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 {
// transformclosure already did all preparation work.
// Prepend captured variables to argument list.
- n.List.Set(append(n.Left.Func.Enter.Slice(), n.List.Slice()...))
+ n.List.Prepend(n.Left.Func.Enter.Slice()...)
n.Left.Func.Enter.Set(nil)