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