use equal? for frozen array comparison in Lexer, skip whitespace with \s+

This commit is contained in:
Tobi Lutke
2026-03-11 07:21:55 -04:00
parent 2b78e4bf72
commit d291e63006
+4 -3
View File
@@ -29,6 +29,7 @@ module Liquid
RUBY_WHITESPACE = [" ", "\t", "\r", "\n", "\f"].freeze RUBY_WHITESPACE = [" ", "\t", "\r", "\n", "\f"].freeze
SINGLE_STRING_LITERAL = /'[^\']*'/ SINGLE_STRING_LITERAL = /'[^\']*'/
WHITESPACE_OR_NOTHING = /\s*/ WHITESPACE_OR_NOTHING = /\s*/
WHITESPACE = /\s+/
SINGLE_COMPARISON_TOKENS = [].tap do |table| SINGLE_COMPARISON_TOKENS = [].tap do |table|
table["<".ord] = COMPARISON_LESS_THAN table["<".ord] = COMPARISON_LESS_THAN
@@ -104,7 +105,7 @@ module Liquid
output = [] output = []
until ss.eos? until ss.eos?
ss.skip(WHITESPACE_OR_NOTHING) ss.skip(WHITESPACE)
break if ss.eos? break if ss.eos?
@@ -114,10 +115,10 @@ module Liquid
if (special = SPECIAL_TABLE[peeked]) if (special = SPECIAL_TABLE[peeked])
ss.scan_byte ss.scan_byte
# Special case for ".." # Special case for ".."
if special == DOT && ss.peek_byte == DOT_ORD if special.equal?(DOT) && ss.peek_byte == DOT_ORD
ss.scan_byte ss.scan_byte
output << DOTDOT output << DOTDOT
elsif special == DASH elsif special.equal?(DASH)
# Special case for negative numbers # Special case for negative numbers
if (peeked_byte = ss.peek_byte) && NUMBER_TABLE[peeked_byte] if (peeked_byte = ss.peek_byte) && NUMBER_TABLE[peeked_byte]
ss.pos -= 1 ss.pos -= 1