Remove macro mutex as it's no longer needed
This commit is contained in:
		@@ -30,17 +30,13 @@ func (mt macroTag) Run(tc *TagContext, block, args []ast.Node) error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(block) == 0 {
 | 
						if len(block) == 0 {
 | 
				
			||||||
		tc.t.macroMtx.Lock()
 | 
					 | 
				
			||||||
		macro, ok := tc.t.macros[name]
 | 
							macro, ok := tc.t.macros[name]
 | 
				
			||||||
		if !ok {
 | 
							if !ok {
 | 
				
			||||||
			return ErrNoSuchMacro
 | 
								return ErrNoSuchMacro
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		tc.t.macroMtx.Unlock()
 | 
					 | 
				
			||||||
		return tc.Execute(macro, nil)
 | 
							return tc.Execute(macro, nil)
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		tc.t.macroMtx.Lock()
 | 
					 | 
				
			||||||
		tc.t.macros[name] = block
 | 
							tc.t.macros[name] = block
 | 
				
			||||||
		tc.t.macroMtx.Unlock()
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								parse.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								parse.go
									
									
									
									
									
								
							@@ -26,7 +26,6 @@ import (
 | 
				
			|||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"go.elara.ws/salix/ast"
 | 
						"go.elara.ws/salix/ast"
 | 
				
			||||||
	"go.elara.ws/salix/parser"
 | 
						"go.elara.ws/salix/parser"
 | 
				
			||||||
@@ -52,12 +51,11 @@ func (n *Namespace) ParseWithName(name string, r io.Reader) (Template, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t := Template{
 | 
						t := Template{
 | 
				
			||||||
		ns:       n,
 | 
							ns:   n,
 | 
				
			||||||
		name:     name,
 | 
							name: name,
 | 
				
			||||||
		ast:      astVal.([]ast.Node),
 | 
							ast:  astVal.([]ast.Node),
 | 
				
			||||||
		tags:     map[string]Tag{},
 | 
							tags: map[string]Tag{},
 | 
				
			||||||
		vars:     map[string]reflect.Value{},
 | 
							vars: map[string]reflect.Value{},
 | 
				
			||||||
		macroMtx: &sync.Mutex{},
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	performWhitespaceMutations(t.ast)
 | 
						performWhitespaceMutations(t.ast)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								salix.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								salix.go
									
									
									
									
									
								
							@@ -60,11 +60,9 @@ type Template struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	escapeHTML bool
 | 
						escapeHTML bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tags map[string]Tag
 | 
						tags   map[string]Tag
 | 
				
			||||||
	vars map[string]reflect.Value
 | 
						vars   map[string]reflect.Value
 | 
				
			||||||
 | 
						macros map[string][]ast.Node
 | 
				
			||||||
	macroMtx *sync.Mutex
 | 
					 | 
				
			||||||
	macros   map[string][]ast.Node
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WithVarMap returns a copy of the template with its variable map set to m.
 | 
					// WithVarMap returns a copy of the template with its variable map set to m.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user