From 649b64ffd484b20113a28263dae6e8830b1d91cb Mon Sep 17 00:00:00 2001 From: Michael Go Date: Thu, 24 Oct 2024 22:43:49 -0300 Subject: [PATCH] more micro optimization --- lib/liquid/tokenizer.rb | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/liquid/tokenizer.rb b/lib/liquid/tokenizer.rb index a3e587c6..81805451 100644 --- a/lib/liquid/tokenizer.rb +++ b/lib/liquid/tokenizer.rb @@ -50,16 +50,24 @@ module Liquid def next_token # possible states: :text, :tag, :variable - c_list = @ss.peek(2) + byte_a = @ss.scan_byte - case c_list - when "{%" - next_tag_token - when "{{" - next_variable_token - else - next_text_token + if byte_a == OPEN_CURLEY + byte_b = @ss.scan_byte + + if byte_b == PERCENTAGE + @ss.pos -= 2 + return next_tag_token + elsif byte_b == OPEN_CURLEY + @ss.pos -= 2 + return next_variable_token + end + + @ss.pos -= 1 end + + @ss.pos -= 1 + next_text_token end def next_text_token