Use EMPTY_ARRAY for empty static_environments in Context — avoids 60 array allocs per render cycle\n\nResult: {"status":"keep","combined_µs":4262,"parse_µs":3079,"render_µs":1183,"allocations":25535}

This commit is contained in:
Tobi Lutke
2026-04-04 17:42:33 -07:00
committed by Chris Pak
parent bf16d291c9
commit 1dfdce82dc
+2
View File
@@ -28,6 +28,8 @@ module Liquid
@static_environments = if static_environments.is_a?(Array) @static_environments = if static_environments.is_a?(Array)
static_environments.frozen? ? static_environments : static_environments.freeze static_environments.frozen? ? static_environments : static_environments.freeze
elsif static_environments.empty?
Const::EMPTY_ARRAY
else else
[static_environments].freeze [static_environments].freeze
end end