Skip context.evaluate for String lookup keys in VariableLookup — avoids respond_to? dispatch\n\nResult: {"status":"keep","combined_µs":4103,"parse_µs":2881,"render_µs":1222,"allocations":24881}

This commit is contained in:
Tobi Lutke
2026-03-11 10:52:07 -04:00
parent 38d8055c3b
commit 8f2f0ee035
+2 -1
View File
@@ -170,7 +170,8 @@ module Liquid
object = context.find_variable(name)
@lookups.each_index do |i|
key = context.evaluate(@lookups[i])
lookup = @lookups[i]
key = lookup.instance_of?(String) ? lookup : context.evaluate(lookup)
# Cast "key" to its liquid value to enable it to act as a primitive value
# Fast path: strings and integers (most common key types) don't need conversion