From de8675f8fbcc43f7ed6069bfecc47f1d8180d222 Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Wed, 11 Mar 2026 10:44:05 -0400 Subject: [PATCH] =?UTF-8?q?Skip=20to=5Fliquid=5Fvalue=20for=20String/Integ?= =?UTF-8?q?er=20keys=20in=20VariableLookup=20=E2=80=94=20avoids=20respond?= =?UTF-8?q?=5Fto=3F=20dispatch\n\nResult:=20{"status":"keep","combined=5F?= =?UTF-8?q?=C2=B5s":4131,"parse=5F=C2=B5s":2893,"render=5F=C2=B5s":1238,"a?= =?UTF-8?q?llocations":25535}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/liquid/variable_lookup.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/liquid/variable_lookup.rb b/lib/liquid/variable_lookup.rb index e5d273de..2cda166b 100644 --- a/lib/liquid/variable_lookup.rb +++ b/lib/liquid/variable_lookup.rb @@ -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