text/template/parse: specify slice capacity in Pipenode.CopyPipe()

The required vars slice capacity is known so it can be specified before appending.

Change-Id: Ifa2fe97602e84198c4d01e5a1b0529f3f65f2df1
GitHub-Last-Rev: a0580df208a1d498968138d63508ae4e30df2ec5
GitHub-Pull-Request: golang/go#34613
Reviewed-on: https://go-review.googlesource.com/c/go/+/197997
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Pantelis Sampaziotis 2019-09-30 21:37:40 +00:00 committed by Andrew Bonventre
parent 8e032b917a
commit f91c850be6

View File

@ -187,7 +187,7 @@ func (p *PipeNode) CopyPipe() *PipeNode {
if p == nil {
return p
}
var vars []*VariableNode
vars := make([]*VariableNode, 0, len(p.Decl))
for _, d := range p.Decl {
vars = append(vars, d.Copy().(*VariableNode))
}