mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
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:
+4
-11
@@ -162,21 +162,14 @@ module Liquid
|
|||||||
@ss.scan(QUOTED_STRING_RAW)
|
@ss.scan(QUOTED_STRING_RAW)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Regex for dotted identifier: name(.name)*
|
||||||
|
DOTTED_ID_REGEX = /[a-zA-Z_][\w-]*\??(?:\.[a-zA-Z_][\w-]*\??)*/
|
||||||
|
|
||||||
# ── Expressions ─────────────────────────────────────────────────
|
# ── Expressions ─────────────────────────────────────────────────
|
||||||
# Scan a simple variable lookup: name(.name)* — no brackets, no filters
|
# Scan a simple variable lookup: name(.name)* — no brackets, no filters
|
||||||
# Returns the string or nil
|
# Returns the string or nil
|
||||||
def scan_dotted_id
|
def scan_dotted_id
|
||||||
start = @ss.pos
|
@ss.scan(DOTTED_ID_REGEX)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Skip a fragment without allocating. Returns length skipped, or 0.
|
# Skip a fragment without allocating. Returns length skipped, or 0.
|
||||||
|
|||||||
Reference in New Issue
Block a user