Skip to content

A platform for community discussion. Free, open, simple.

PERF: Memoize `TopicView#gaps` results.

Guo Xiang Tan5cef4e281be6
diff --git a/lib/topic_view.rb b/lib/topic_view.rb
index cc06d251282..2b3dc236c4f 100644
--- a/lib/topic_view.rb
+++ b/lib/topic_view.rb
@@ -103,7 +103,7 @@ class TopicView
def gaps
return unless @contains_gaps
- Gaps.new(filtered_post_ids, unfiltered_posts.order(:sort_order).pluck(:id))
+ @gaps ||= Gaps.new(filtered_post_ids, unfiltered_posts.order(:sort_order).pluck(:id))
end
def last_post