From cb162195529655c40e0db82b13eeedd062a1745d Mon Sep 17 00:00:00 2001 From: Michael Go Date: Tue, 22 Oct 2024 17:06:20 -0300 Subject: [PATCH] faster BlockBody variable matching --- lib/liquid/block_body.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/liquid/block_body.rb b/lib/liquid/block_body.rb index ec40e2129..964758b65 100644 --- a/lib/liquid/block_body.rb +++ b/lib/liquid/block_body.rb @@ -246,10 +246,16 @@ def render_node(context, output, node) 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 = token[i..parse_end] return Variable.new(markup, parse_context) end + BlockBody.raise_missing_variable_terminator(token, parse_context) end