From: Pantelis Sampaziotis Date: Mon, 30 Sep 2019 21:37:40 +0000 (+0000) Subject: text/template/parse: specify slice capacity in Pipenode.CopyPipe() X-Git-Tag: go1.14beta1~915 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f91c850be62416d0aaa70e77831c8ba3e1ee2b1e;p=gostls13.git 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 --- diff --git a/src/text/template/parse/node.go b/src/text/template/parse/node.go index 1174a4b970..74552c293f 100644 --- a/src/text/template/parse/node.go +++ b/src/text/template/parse/node.go @@ -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)) }