Commit 9fa94326 authored by Yorick Peterse's avatar Yorick Peterse

Memoize object class titles

For an issue with around 200 notes this cuts down timings by around 150
milliseconds.
parent 8c49eaa9
......@@ -22,6 +22,10 @@ module Banzai
@data_reference ||= "data-#{object_name.dasherize}"
end
def self.object_class_title
@object_title ||= object_class.name.titleize
end
# Public: Find references in text (like `!123` for merge requests)
#
# AnyReferenceFilter.references_in(text) do |match, id, project_ref, matches|
......@@ -53,6 +57,10 @@ module Banzai
self.class.object_sym
end
def object_class_title
self.class.object_class_title
end
def references_in(*args, &block)
self.class.references_in(*args, &block)
end
......@@ -206,7 +214,7 @@ module Banzai
end
def object_link_title(object)
"#{object_class.name.titleize}: #{object.title}"
"#{object_class_title}: #{object.title}"
end
def object_link_text(object, matches)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment