Skip to content

Commit

Permalink
avoid allocating new empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmichaelgo committed Nov 4, 2024
1 parent 06f4422 commit 1f3ea73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/liquid/parse_tree_visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def visit(context = nil)
protected

def children
@node.respond_to?(:nodelist) ? Array(@node.nodelist) : []
@node.respond_to?(:nodelist) ? Array(@node.nodelist) : Const::EMPTY_ARRAY
end
end
end
2 changes: 1 addition & 1 deletion lib/liquid/variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def strict_parse(markup)
@name = parse_context.parse_expression(p.expression)
while p.consume?(:pipe)
filtername = p.consume(:id)
filterargs = p.consume?(:colon) ? parse_filterargs(p) : []
filterargs = p.consume?(:colon) ? parse_filterargs(p) : Const::EMPTY_ARRAY
@filters << parse_filter_expressions(filtername, filterargs)
end
p.consume(:end_of_string)
Expand Down

0 comments on commit 1f3ea73

Please sign in to comment.