Avoid expr_markup byteslice when name is entire markup string (no whitespace, no filters)\n\nResult: {"status":"keep","combined_µs":4277,"parse_µs":3057,"render_µs":1220,"allocations":27026}

This commit is contained in:
Tobi Lutke
2026-03-11 10:12:26 -04:00
parent a249010cef
commit c252d50aa0
+6 -2
View File
@@ -151,8 +151,12 @@ module Liquid
pos += 1
end
# Resolve the name expression
expr_markup = markup.byteslice(name_start, name_end - name_start)
# Resolve the name expression — avoid byteslice when markup is already the name
expr_markup = if name_start == 0 && name_end == len
markup # no whitespace, no filters — reuse the string
else
markup.byteslice(name_start, name_end - name_start)
end
cache = parse_context.expression_cache
ss = parse_context.string_scanner