mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-17 09:50:48 -07:00
hoist write score check out of render loop: skip increment_write_score when no limits active
This commit is contained in:
@@ -297,7 +297,11 @@ module Liquid
|
|||||||
def render_to_output_buffer(context, output)
|
def render_to_output_buffer(context, output)
|
||||||
freeze unless frozen?
|
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
|
idx = 0
|
||||||
while (node = @nodelist[idx])
|
while (node = @nodelist[idx])
|
||||||
@@ -312,7 +316,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
context.resource_limits.increment_write_score(output)
|
resource_limits.increment_write_score(output) if check_write
|
||||||
end
|
end
|
||||||
|
|
||||||
output
|
output
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class ResourceLimits
|
class ResourceLimits
|
||||||
attr_accessor :render_length_limit, :render_score_limit, :assign_score_limit
|
attr_accessor :render_length_limit, :render_score_limit, :assign_score_limit
|
||||||
attr_reader :render_score, :assign_score
|
attr_reader :render_score, :assign_score, :last_capture_length
|
||||||
|
|
||||||
def initialize(limits)
|
def initialize(limits)
|
||||||
@render_length_limit = limits[:render_length_limit]
|
@render_length_limit = limits[:render_length_limit]
|
||||||
|
|||||||
Reference in New Issue
Block a user