mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07:00
Recycle the array buffer in BlockBody#render
This commit is contained in:
@@ -68,7 +68,8 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
output = []
|
@output ||= []
|
||||||
|
@output.clear
|
||||||
context.resource_limits.render_score += @nodelist.length
|
context.resource_limits.render_score += @nodelist.length
|
||||||
|
|
||||||
@nodelist.each do |token|
|
@nodelist.each do |token|
|
||||||
@@ -87,16 +88,16 @@ module Liquid
|
|||||||
token_output = render_token(token, context)
|
token_output = render_token(token, context)
|
||||||
|
|
||||||
unless token.is_a?(Block) && token.blank?
|
unless token.is_a?(Block) && token.blank?
|
||||||
output << token_output
|
@output << token_output
|
||||||
end
|
end
|
||||||
rescue MemoryError => e
|
rescue MemoryError => e
|
||||||
raise e
|
raise e
|
||||||
rescue ::StandardError => e
|
rescue ::StandardError => e
|
||||||
output << context.handle_error(e, token)
|
@output << context.handle_error(e, token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output.join
|
@output.join
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
Reference in New Issue
Block a user