Replace manual scan_dotted_id with regex\n\nResult: {"status":"keep","combined_µs":4121,"parse_µs":2812,"render_µs":1309,"allocations":25535}

This commit is contained in:
Tobi Lutke
2026-03-11 10:42:07 -04:00
parent fd4a7af290
commit 71e22e6a84
+4 -11
View File
@@ -162,21 +162,14 @@ module Liquid
@ss.scan(QUOTED_STRING_RAW)
end
# Regex for dotted identifier: name(.name)*
DOTTED_ID_REGEX = /[a-zA-Z_][\w-]*\??(?:\.[a-zA-Z_][\w-]*\??)*/
# ── Expressions ─────────────────────────────────────────────────
# Scan a simple variable lookup: name(.name)* — no brackets, no filters
# Returns the string or nil
def scan_dotted_id
start = @ss.pos
return unless scan_id
while @ss.peek_byte == DOT
@ss.scan_byte
unless scan_id
@ss.pos -= 1 # rewind the dot
break
end
end
@source.byteslice(start, @ss.pos - start)
@ss.scan(DOTTED_ID_REGEX)
end
# Skip a fragment without allocating. Returns length skipped, or 0.