Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid allocating new empty array #1843

Merged
merged 1 commit into from
Nov 4, 2024
Merged

avoid allocating new empty array #1843

merged 1 commit into from
Nov 4, 2024

Conversation

ggmichaelgo
Copy link
Contributor

@ggmichaelgo ggmichaelgo commented Nov 1, 2024

This improves the parsing speed slightly by avoiding allocating a new empty array when parsing filter arguments in Liquid templates.

@ggmichaelgo ggmichaelgo requested review from ianks, a team and Maaarcocr November 1, 2024 22:17
@@ -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) : EMPTY_ARRAY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the empty array from const.rb here

@ggmichaelgo ggmichaelgo merged commit 8d86613 into main Nov 4, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants