From ee4aa95dc37ae095e23288e3846e9762ae8c48df Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Tue, 31 Oct 2023 08:02:29 -0700 Subject: [PATCH] Remove macro mutex as it's no longer needed --- macro_tag.go | 4 ---- parse.go | 12 +++++------- salix.go | 8 +++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/macro_tag.go b/macro_tag.go index ad53027..076f67b 100644 --- a/macro_tag.go +++ b/macro_tag.go @@ -30,17 +30,13 @@ func (mt macroTag) Run(tc *TagContext, block, args []ast.Node) error { } if len(block) == 0 { - tc.t.macroMtx.Lock() macro, ok := tc.t.macros[name] if !ok { return ErrNoSuchMacro } - tc.t.macroMtx.Unlock() return tc.Execute(macro, nil) } else { - tc.t.macroMtx.Lock() tc.t.macros[name] = block - tc.t.macroMtx.Unlock() } return nil diff --git a/parse.go b/parse.go index 57eecf3..db00a0a 100644 --- a/parse.go +++ b/parse.go @@ -26,7 +26,6 @@ import ( "path/filepath" "reflect" "strings" - "sync" "go.elara.ws/salix/ast" "go.elara.ws/salix/parser" @@ -52,12 +51,11 @@ func (n *Namespace) ParseWithName(name string, r io.Reader) (Template, error) { } t := Template{ - ns: n, - name: name, - ast: astVal.([]ast.Node), - tags: map[string]Tag{}, - vars: map[string]reflect.Value{}, - macroMtx: &sync.Mutex{}, + ns: n, + name: name, + ast: astVal.([]ast.Node), + tags: map[string]Tag{}, + vars: map[string]reflect.Value{}, } performWhitespaceMutations(t.ast) diff --git a/salix.go b/salix.go index 2ea6508..9e0870c 100644 --- a/salix.go +++ b/salix.go @@ -60,11 +60,9 @@ type Template struct { escapeHTML bool - tags map[string]Tag - vars map[string]reflect.Value - - macroMtx *sync.Mutex - macros map[string][]ast.Node + tags map[string]Tag + vars map[string]reflect.Value + macros map[string][]ast.Node } // WithVarMap returns a copy of the template with its variable map set to m.