From 58321d0783b29d5fbac92eb4404d4d63616c407a Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 7 Sep 2017 21:35:16 +0800 Subject: [PATCH] PERF: Remove `Object#present?` check introduced in https://github.com/discourse/discourse/commit/e0d5d9670ab2d0fb923fef54e3bdcbbcfc524fb1. --- lib/filter_best_posts.rb | 2 +- lib/topic_view.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/filter_best_posts.rb b/lib/filter_best_posts.rb index 960ee136f7e..b5171497083 100644 --- a/lib/filter_best_posts.rb +++ b/lib/filter_best_posts.rb @@ -15,7 +15,7 @@ class FilterBestPosts def filter @posts = if @min_replies && @topic.posts_count < @min_replies + 1 - [] + Post.none else filter_posts_liked_by_moderators setup_posts diff --git a/lib/topic_view.rb b/lib/topic_view.rb index 06e5d0921df..0e73dd8af3c 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -66,7 +66,7 @@ class TopicView filter_posts(options) - if @posts.present? + if @posts if (added_fields = User.whitelisted_user_custom_fields(@guardian)).present? @user_custom_fields = User.custom_fields_for_ids(@posts.pluck(:user_id), added_fields) end @@ -388,7 +388,7 @@ class TopicView max = [max, post_count].min - return @posts = [] if min > max + return @posts = Post.none if min > max min = [[min, max].min, 0].max