Skip to content

Commit

Permalink
refactor: reduce memory allocations during parsing and generation (a-…
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h authored and joerdav committed Nov 27, 2023
1 parent 6342b13 commit f08e05a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.480
0.2.481
12 changes: 2 additions & 10 deletions parser/v2/ifexpressionparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,10 @@ func (elseIfExpressionParser) Parse(pi *parse.Input) (r ElseIfExpression, ok boo

// Read the 'Then' nodes.
// If there's no match, there's a problem in the template nodes.
<<<<<<< HEAD
np := newTemplateNodeParser(untilElseIfElseOrEnd, "else expression or closing brace")
if r.Then, ok, err = np.Parse(pi); err != nil || !ok {
err = parse.Error("if: expected nodes, but none were found", pi.Position())
||||||| parent of 47341d0 (WIP: Warn when using legacy calls)
np := newTemplateNodeParser(parse.Any(StripType(elseIfExpression), StripType(elseExpression), StripType(closeBraceWithOptionalPadding)), "else expression or closing brace")
if r.Then, ok, err = Must[[]Node](np, "if: expected nodes, but none were found").Parse(pi); err != nil || !ok {
=======
np := newTemplateNodeParser(parse.Any(StripType(elseIfExpression), StripType(elseExpression), StripType(closeBraceWithOptionalPadding)), "else expression or closing brace")
var thenNodes Nodes
if thenNodes, ok, err = Must[Nodes](np, "if: expected nodes, but none were found").Parse(pi); err != nil || !ok {
>>>>>>> 47341d0 (WIP: Warn when using legacy calls)
if thenNodes, ok, err = np.Parse(pi); err != nil || !ok {
err = parse.Error("if: expected nodes, but none were found", pi.Position())
return
}
r.Then = thenNodes.Nodes
Expand Down

0 comments on commit f08e05a

Please sign in to comment.