summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-08-03 21:00:20 -0400
committerRobert Speicher <rspeicher@gmail.com>2017-08-03 22:48:51 -0400
commit01dc8e6d66598c42edb58e35c7da79c3b4cad425 (patch)
treeee278634a4b7a1107f2a9830eb5c45129d2866e7
parent93e96c3fcf30c476df332a7e5e762134ffb5da3e (diff)
downloadgitlab-ce-rs-minor-banzai-perf.tar.gz
Don't bother going through an entire Banzai pipeline for empty textrs-minor-banzai-perf
This bails out of `cacheless_render` immediately unless the provided text is present, since there's no point. This is a slight improvement in our test performance. Across the creation of 1,000 `Namespace` records, which caches the `description` field and which is blank by default in its factory, this saves about four seconds, which... sure. Why not.
-rw-r--r--lib/banzai/renderer.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb
index c7801cb5baf..ad08c0905e2 100644
--- a/lib/banzai/renderer.rb
+++ b/lib/banzai/renderer.rb
@@ -132,6 +132,8 @@ module Banzai
end
def self.cacheless_render(text, context = {})
+ return text.to_s unless text.present?
+
Gitlab::Metrics.measure(:banzai_cacheless_render) do
result = render_result(text, context)