Followup to https://golang.org/cl/197997
If you know the number of elements, you don't need append at all.
Either use append to grow, or allocate and index. Here we choose
number 2.
Change-Id: Ic58637231789640ff7b293ece04a95a8de7ccf8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/198097
Reviewed-by: Ian Lance Taylor <iant@golang.org>
if p == nil {
return p
}
- vars := make([]*VariableNode, 0, len(p.Decl))
- for _, d := range p.Decl {
- vars = append(vars, d.Copy().(*VariableNode))
+ vars := make([]*VariableNode, len(p.Decl))
+ for i, d := range p.Decl {
+ vars[i] = d.Copy().(*VariableNode)
}
n := p.tr.newPipeline(p.Pos, p.Line, vars)
n.IsAssign = p.IsAssign