From d9a4ca5975b4fb91b147930d863f0bb4b9619a64 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 21 Jun 2016 17:07:17 +0200 Subject: Move pre_process into render_result The method Banzai::Renderer.pre_process would always be called, regardless of whether the Markdown to render was already cached or not. In cache the document _was_ cached the output of the pre-processing pipeline was ignored resulting in it doing nothing but wasting CPU cycles. This commit moves Banzai::Renderer.pre_process into Banzai::Renderer.render_result so that it's _only_ used when needed. --- lib/banzai/renderer.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/banzai/renderer.rb') diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb index c14a9c4c722..6718acdef7e 100644 --- a/lib/banzai/renderer.rb +++ b/lib/banzai/renderer.rb @@ -30,13 +30,9 @@ module Banzai end def self.render_result(text, context = {}) - Pipeline[context[:pipeline]].call(text, context) - end + text = Pipeline[:pre_process].to_html(text, context) if text - def self.pre_process(text, context) - pipeline = Pipeline[:pre_process] - - pipeline.to_html(text, context) + Pipeline[context[:pipeline]].call(text, context) end # Perform post-processing on an HTML String -- cgit v1.2.1