File tree Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -62,26 +62,13 @@ func builtins() FuncMap {
62
62
}
63
63
}
64
64
65
- var builtinFuncsOnce struct {
66
- sync.Once
67
- v map [string ]reflect.Value
68
- }
69
-
70
- // builtinFuncsOnce lazily computes & caches the builtinFuncs map.
71
- // TODO: revert this back to a global map once golang.org/issue/2559 is fixed.
72
- func builtinFuncs () map [string ]reflect.Value {
73
- builtinFuncsOnce .Do (func () {
74
- builtinFuncsOnce .v = createValueFuncs (builtins ())
75
- })
76
- return builtinFuncsOnce .v
77
- }
78
-
79
- // createValueFuncs turns a FuncMap into a map[string]reflect.Value
80
- func createValueFuncs (funcMap FuncMap ) map [string ]reflect.Value {
81
- m := make (map [string ]reflect.Value )
65
+ // builtinFuncs lazily computes & caches the builtinFuncs map.
66
+ var builtinFuncs = sync .OnceValue (func () map [string ]reflect.Value {
67
+ funcMap := builtins ()
68
+ m := make (map [string ]reflect.Value , len (funcMap ))
82
69
addValueFuncs (m , funcMap )
83
70
return m
84
- }
71
+ })
85
72
86
73
// addValueFuncs adds to values the functions in funcs, converting them to reflect.Values.
87
74
func addValueFuncs (out map [string ]reflect.Value , in FuncMap ) {
You can’t perform that action at this time.
0 commit comments