From 087ed84367537ac168ed3e00bb7eb4bd582dc3d0 Mon Sep 17 00:00:00 2001 From: luigi <007.lva@gmail.com> Date: Sat, 9 Jan 2021 18:32:01 -0500 Subject: Optimize map { ... }.compact calls (#15513) * Optimize map { ... }.compact using Enumerable#filter_map, supported since Ruby 2.7 * Add poyfill for Enumerable#filter_map --- app/services/activitypub/process_poll_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/services/activitypub/process_poll_service.rb') diff --git a/app/services/activitypub/process_poll_service.rb b/app/services/activitypub/process_poll_service.rb index 903b6a78a..d83e614d8 100644 --- a/app/services/activitypub/process_poll_service.rb +++ b/app/services/activitypub/process_poll_service.rb @@ -30,7 +30,7 @@ class ActivityPub::ProcessPollService < BaseService voters_count = @json['votersCount'] - latest_options = items.map { |item| item['name'].presence || item['content'] }.compact + latest_options = items.filter_map { |item| item['name'].presence || item['content'] } # If for some reasons the options were changed, it invalidates all previous # votes, so we need to remove them -- cgit