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-04-04 17:42:33 -07:00
committed by Chris Pak
parent 3f10ac702c
commit 0e5edcc9da
+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