From 1a79cf62661efb00038208b4049fad2cd40ad15a Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Wed, 11 Mar 2026 07:26:40 -0400 Subject: [PATCH] fast-path variable_lookups: skip mutable string alloc when no dot/bracket follows --- lib/liquid/parser.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/liquid/parser.rb b/lib/liquid/parser.rb index 645dfa3a..0d0d0d01 100644 --- a/lib/liquid/parser.rb +++ b/lib/liquid/parser.rb @@ -83,6 +83,9 @@ module Liquid end def variable_lookups + # Fast path: no lookups at all (most common case for simple identifiers) + return "" unless look(:dot) || look(:open_square) + str = +"" loop do if look(:open_square)