From ddb969af8b30d5f95800a6912387d8c78fbcac5e Mon Sep 17 00:00:00 2001 From: Michael Go Date: Thu, 24 Oct 2024 22:03:12 -0300 Subject: [PATCH] more micro optimization --- lib/liquid/tokenizer.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/liquid/tokenizer.rb b/lib/liquid/tokenizer.rb index a03533fe..fb0cdf69 100644 --- a/lib/liquid/tokenizer.rb +++ b/lib/liquid/tokenizer.rb @@ -75,7 +75,6 @@ module Liquid end @ss.pos -= 2 - @ss.string.byteslice(start, @ss.pos - start) end @@ -85,16 +84,21 @@ module Liquid found_variable_end = false # it is possible to see a {% before a }} so we need to check for that + byte_a = @ss.peek_byte + @ss.pos += 1 + until @ss.eos? - case @ss.peek(2) - when "}}" - @ss.pos += 2 + byte_b = @ss.peek_byte + + if byte_a == CLOSE_CURLEY && byte_b == CLOSE_CURLEY + @ss.pos += 1 found_variable_end = true break - when "{%" + elsif byte_a == OPEN_CURLEY && byte_b == PERCENTAGE return next_tag_token(start) end + byte_a = byte_b @ss.pos += 1 end