]> Cypherpunks repositories - gostls13.git/commitdiff
text/template: make use of maps.Copy for Template.Clone
authorJes Cok <xigua67damn@gmail.com>
Thu, 12 Sep 2024 15:46:41 +0000 (15:46 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 13 Sep 2024 17:00:52 +0000 (17:00 +0000)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/text/template/template.go

index 86fd3f122a120609e3253a85ee13ef420b7de745..78067af2add4ae529c660ddcdc5cc4c559d3b085 100644 (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
 }