Skip to_liquid_value for String/Integer keys in VariableLookup — avoids respond_to? dispatch\n\nResult: {"status":"keep","combined_µs":4131,"parse_µs":2893,"render_µs":1238,"allocations":25535}

This commit is contained in:
Tobi Lutke
2026-03-11 10:44:05 -04:00
parent 1a019151eb
commit 22b5ff1587
+4 -1
View File
@@ -173,7 +173,10 @@ module Liquid
key = context.evaluate(@lookups[i])
# Cast "key" to its liquid value to enable it to act as a primitive value
key = Liquid::Utils.to_liquid_value(key)
# Fast path: strings and integers (most common key types) don't need conversion
unless key.instance_of?(String) || key.instance_of?(Integer)
key = Liquid::Utils.to_liquid_value(key)
end
# If object is a hash- or array-like object we look for the
# presence of the key and if its available we return it