mirror of
https://github.com/semihalev/twig.git
synced 2026-03-14 13:55:46 +01:00
Performance and stability improvements
- Fixed concurrency safety issues in template cache and loaders - Implemented attribute access caching to reduce reflection usage - Added memory pooling for render contexts and string buffers - Improved error handling for more resilient template loading - Added detailed benchmarks showing performance improvements - Updated documentation with progress and improvements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f9b283c393
commit
52693a0b4a
7 changed files with 444 additions and 58 deletions
|
|
@ -121,6 +121,9 @@ func (l *CompiledLoader) LoadAll(engine *Engine) error {
|
|||
return fmt.Errorf("failed to read directory: %w", err)
|
||||
}
|
||||
|
||||
// Collect errors during loading
|
||||
var loadErrors []error
|
||||
|
||||
// Load each compiled template
|
||||
for _, file := range files {
|
||||
// Skip directories
|
||||
|
|
@ -136,11 +139,24 @@ func (l *CompiledLoader) LoadAll(engine *Engine) error {
|
|||
|
||||
// Load the template
|
||||
if err := l.LoadCompiled(engine, name); err != nil {
|
||||
return fmt.Errorf("failed to load compiled template %s: %w", name, err)
|
||||
// Collect the error but continue loading other templates
|
||||
loadErrors = append(loadErrors, fmt.Errorf("failed to load compiled template %s: %w", name, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there were any errors, return a combined error
|
||||
if len(loadErrors) > 0 {
|
||||
var errMsg string
|
||||
for i, err := range loadErrors {
|
||||
if i > 0 {
|
||||
errMsg += "; "
|
||||
}
|
||||
errMsg += err.Error()
|
||||
}
|
||||
return fmt.Errorf("errors loading compiled templates: %s", errMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue