Recycle the array buffer in BlockBody#render

This commit is contained in:
Lourens Naudé
2015-05-05 23:02:08 -04:00
parent 5a48edae6a
commit 0e38f88b58
+5 -4
View File
@@ -68,7 +68,8 @@ module Liquid
end
def render(context)
output = []
@output ||= []
@output.clear
context.resource_limits.render_score += @nodelist.length
@nodelist.each do |token|
@@ -87,16 +88,16 @@ module Liquid
token_output = render_token(token, context)
unless token.is_a?(Block) && token.blank?
output << token_output
@output << token_output
end
rescue MemoryError => e
raise e
rescue ::StandardError => e
output << context.handle_error(e, token)
@output << context.handle_error(e, token)
end
end
output.join
@output.join
end
private