From 30f9200fc7f6e90e8bfd4043e76d43b110637f7b Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 29 Aug 2019 11:35:31 +1000 Subject: [PATCH] PERF: avoid filtering shared drafts when not used In some very specific cases (large sites) shared drafts can introduce a performance hit due to the mechanism used to filter out topics This avoids the entire process when shared drafts are not enabled --- lib/topic_query.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 1b90719454..1a4a5821e1 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -589,6 +589,11 @@ class TopicQuery end def apply_shared_drafts(result, category_id, options) + + # PERF: avoid any penalty if there are no shared drafts enabled + # on some sites the cost can be high eg: gearbox + return result if SiteSetting.shared_drafts_category == "" + drafts_category_id = SiteSetting.shared_drafts_category.to_i viewing_shared = category_id && category_id == drafts_category_id can_create_shared = guardian.can_create_shared_draft?