mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
store scores in regs
This commit is contained in:
@@ -218,6 +218,9 @@ module Liquid
|
||||
def render_to_output_buffer(context, output)
|
||||
freeze unless frozen?
|
||||
|
||||
context.registers[:render_scores] ||= []
|
||||
context.registers[:render_scores] << @nodelist.length
|
||||
|
||||
context.resource_limits.increment_render_score(@nodelist.length)
|
||||
|
||||
idx = 0
|
||||
@@ -233,6 +236,11 @@ module Liquid
|
||||
end
|
||||
idx += 1
|
||||
|
||||
context.registers[:write_scores] ||= []
|
||||
|
||||
last_captured = context.registers[:write_scores].any? ? context.registers[:write_scores].last : 0
|
||||
context.registers[:write_scores] << (output.bytesize - last_captured)
|
||||
|
||||
context.resource_limits.increment_write_score(output)
|
||||
end
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ module Liquid
|
||||
def render_to_output_buffer(context, output)
|
||||
val = @from.render(context)
|
||||
context.scopes.last[@to] = val
|
||||
|
||||
context.registers[:assign_scores] ||= []
|
||||
context.registers[:assign_scores] << assign_score_of(val)
|
||||
|
||||
context.resource_limits.increment_assign_score(assign_score_of(val))
|
||||
output
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user