Merge pull request #1833 from Shopify/fast-variable-parse

Faster Variable BlockBody Matching
This commit is contained in:
Michael Go
2024-10-28 15:28:04 -03:00
committed by GitHub
+9 -2
View File
@@ -246,10 +246,17 @@ module Liquid
end
def create_variable(token, parse_context)
if token =~ ContentOfVariable
markup = Regexp.last_match(1)
if token.end_with?("}}")
i = 2
i = 3 if token[i] == "-"
parse_end = token.length - 3
parse_end -= 1 if token[parse_end] == "-"
markup_end = parse_end - i + 1
markup = markup_end <= 0 ? "" : token.byteslice(i, markup_end)
return Variable.new(markup, parse_context)
end
BlockBody.raise_missing_variable_terminator(token, parse_context)
end