hoist write score check out of render loop: skip increment_write_score when no limits active

This commit is contained in:
Tobi Lutke
2026-04-04 17:42:32 -07:00
committed by Chris Pak
parent 27fcb3a4c9
commit 48a2fae5f6
2 changed files with 7 additions and 2 deletions
+6 -2
View File
@@ -297,7 +297,11 @@ module Liquid
def render_to_output_buffer(context, output)
freeze unless frozen?
context.resource_limits.increment_render_score(@nodelist.length)
resource_limits = context.resource_limits
resource_limits.increment_render_score(@nodelist.length)
# Check if we need per-node write score tracking
check_write = resource_limits.render_length_limit || resource_limits.last_capture_length
idx = 0
while (node = @nodelist[idx])
@@ -312,7 +316,7 @@ module Liquid
end
idx += 1
context.resource_limits.increment_write_score(output)
resource_limits.increment_write_score(output) if check_write
end
output
+1
View File
@@ -9,6 +9,7 @@ module Liquid
:cumulative_assign_score_limit
attr_reader :render_score,
:assign_score,
:last_capture_length,
:cumulative_render_score,
:cumulative_assign_score