PERF: Prefer `exists?` instead of loading AR object.

This commit is contained in:
Guo Xiang Tan 2018-06-01 09:44:14 +08:00
parent 50be06af47
commit 9ef61e0af5
1 changed files with 1 additions and 1 deletions

View File

@ -655,7 +655,7 @@ SQL
end
def changed_to_category(new_category)
return true if new_category.blank? || Category.find_by(topic_id: id).present?
return true if new_category.blank? || Category.exists?(topic_id: id)
return false if new_category.id == SiteSetting.uncategorized_category_id && !SiteSetting.allow_uncategorized_topics
Topic.transaction do