mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
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:
@@ -173,7 +173,10 @@ module Liquid
|
|||||||
key = context.evaluate(@lookups[i])
|
key = context.evaluate(@lookups[i])
|
||||||
|
|
||||||
# Cast "key" to its liquid value to enable it to act as a primitive value
|
# 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
|
# If object is a hash- or array-like object we look for the
|
||||||
# presence of the key and if its available we return it
|
# presence of the key and if its available we return it
|
||||||
|
|||||||
Reference in New Issue
Block a user