mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Move start of profiling to a Document#render_to_output_buffer patch
This commit is contained in:
@@ -42,7 +42,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
@body.render(context)
|
render_to_output_buffer(context, +'')
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ module Liquid
|
|||||||
end
|
end
|
||||||
BlockBody.prepend(BlockBodyProfilingHook)
|
BlockBody.prepend(BlockBodyProfilingHook)
|
||||||
|
|
||||||
|
module DocumentProfilingHook
|
||||||
|
def render_to_output_buffer(context, output)
|
||||||
|
return super unless context.profiler
|
||||||
|
context.profiler.profile { super }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Document.prepend(DocumentProfilingHook)
|
||||||
|
|
||||||
module ContextProfilingHook
|
module ContextProfilingHook
|
||||||
attr_accessor :profiler
|
attr_accessor :profiler
|
||||||
|
|
||||||
|
|||||||
@@ -199,9 +199,7 @@ module Liquid
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
# render the nodelist.
|
# render the nodelist.
|
||||||
with_profiling(context) do
|
@root.render_to_output_buffer(context, output || +'')
|
||||||
@root.render_to_output_buffer(context, output || +'')
|
|
||||||
end
|
|
||||||
rescue Liquid::MemoryError => e
|
rescue Liquid::MemoryError => e
|
||||||
context.handle_error(e)
|
context.handle_error(e)
|
||||||
ensure
|
ensure
|
||||||
@@ -224,11 +222,6 @@ module Liquid
|
|||||||
Tokenizer.new(source, @line_numbers)
|
Tokenizer.new(source, @line_numbers)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_profiling(context)
|
|
||||||
return yield unless context.profiler
|
|
||||||
context.profiler.profile { yield }
|
|
||||||
end
|
|
||||||
|
|
||||||
def apply_options_to_context(context, options)
|
def apply_options_to_context(context, options)
|
||||||
context.add_filters(options[:filters]) if options[:filters]
|
context.add_filters(options[:filters]) if options[:filters]
|
||||||
context.global_filter = options[:global_filter] if options[:global_filter]
|
context.global_filter = options[:global_filter] if options[:global_filter]
|
||||||
|
|||||||
Reference in New Issue
Block a user