1
0
mirror of https://github.com/golang/go synced 2024-11-25 08:07:57 -07:00

text/template: make use of maps.Copy for Template.Clone

Change-Id: Ia79ac11b8be1d3b3629d9eda1fab0f63af5802cd
This commit is contained in:
Jes Cok 2024-09-12 23:34:28 +08:00
parent 0ee5d20b1f
commit 0a6bd6e84a

View File

@ -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
}