From: Jes Cok Date: Thu, 12 Sep 2024 15:46:41 +0000 (+0000) Subject: text/template: make use of maps.Copy for Template.Clone X-Git-Tag: go1.24rc1~912 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fc97288e2607480199755dea9dbd5484f0b4de74;p=gostls13.git text/template: make use of maps.Copy for Template.Clone Change-Id: I1da668223b599867afe5483384b458482624adc5 GitHub-Last-Rev: 0a6bd6e84ac4c744d27d6ac87d877889209f386d GitHub-Pull-Request: golang/go#69423 Reviewed-on: https://go-review.googlesource.com/c/go/+/612717 LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Tim King Reviewed-by: Ian Lance Taylor --- diff --git a/src/text/template/template.go b/src/text/template/template.go index 86fd3f122a..78067af2ad 100644 --- a/src/text/template/template.go +++ b/src/text/template/template.go @@ -5,6 +5,7 @@ package template import ( + "maps" "reflect" "sync" "text/template/parse" @@ -102,12 +103,8 @@ func (t *Template) Clone() (*Template, error) { } t.muFuncs.RLock() defer t.muFuncs.RUnlock() - for k, v := range t.parseFuncs { - nt.parseFuncs[k] = v - } - for k, v := range t.execFuncs { - nt.execFuncs[k] = v - } + maps.Copy(nt.parseFuncs, t.parseFuncs) + maps.Copy(nt.execFuncs, t.execFuncs) return nt, nil }