mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -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)
|
||||
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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module Liquid
|
||||
class ResourceLimits
|
||||
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)
|
||||
@render_length_limit = limits[:render_length_limit]
|
||||
|
||||
Reference in New Issue
Block a user