avoid using StringScanner eos

This commit is contained in:
Michael Go
2024-10-30 13:45:10 -03:00
parent f00670cb01
commit ffce6de8bb
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -181,7 +181,7 @@ module Liquid
@output << DOTDOT
elsif special == DASH
# Special case for negative numbers
if !@ss.eos? && NUMBER_TABLE[@ss.peek_byte]
if (peeked_byte = @ss.peek_byte) && NUMBER_TABLE[peeked_byte]
@ss.pos -= 1
@output << [:number, @ss.scan(NUMBER_LITERAL)]
else
@@ -192,7 +192,7 @@ module Liquid
end
elsif (sub_table = TWO_CHARS_COMPARISON_JUMP_TABLE[peeked])
@ss.scan_byte
if !@ss.eos? && (found = sub_table[@ss.peek_byte])
if (peeked_byte = @ss.peek_byte) && (found = sub_table[peeked_byte])
@output << found
@ss.scan_byte
else
@@ -200,7 +200,7 @@ module Liquid
end
elsif (sub_table = COMPARISON_JUMP_TABLE[peeked])
@ss.scan_byte
if !@ss.eos? && (found = sub_table[@ss.peek_byte])
if (peeked_byte = @ss.peek_byte) && (found = sub_table[peeked_byte])
@output << found
@ss.scan_byte
else