more micro optimization

This commit is contained in:
Michael Go
2024-10-30 13:54:00 -03:00
parent 128935dcef
commit ddb969af8b
+9 -5
View File
@@ -75,7 +75,6 @@ module Liquid
end end
@ss.pos -= 2 @ss.pos -= 2
@ss.string.byteslice(start, @ss.pos - start) @ss.string.byteslice(start, @ss.pos - start)
end end
@@ -85,16 +84,21 @@ module Liquid
found_variable_end = false found_variable_end = false
# it is possible to see a {% before a }} so we need to check for that # 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? until @ss.eos?
case @ss.peek(2) byte_b = @ss.peek_byte
when "}}"
@ss.pos += 2 if byte_a == CLOSE_CURLEY && byte_b == CLOSE_CURLEY
@ss.pos += 1
found_variable_end = true found_variable_end = true
break break
when "{%" elsif byte_a == OPEN_CURLEY && byte_b == PERCENTAGE
return next_tag_token(start) return next_tag_token(start)
end end
byte_a = byte_b
@ss.pos += 1 @ss.pos += 1
end end