Don't bother going through an entire Banzai pipeline for empty text

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.
This commit is contained in:
Robert Speicher 2017-08-03 21:00:20 -04:00
parent 93e96c3fcf
commit 01dc8e6d66

View file

@ -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)