about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorluigi <007.lva@gmail.com>2021-01-09 18:32:01 -0500
committerGitHub <noreply@github.com>2021-01-10 00:32:01 +0100
commit087ed84367537ac168ed3e00bb7eb4bd582dc3d0 (patch)
tree2374e63ef1aabe4b9991dd30c4eba8adfec89839 /app/models/status.rb
parent93951431269403201550e914dee508a522becf8b (diff)
Optimize map { ... }.compact calls (#15513)
* Optimize map { ... }.compact

using Enumerable#filter_map, supported since Ruby 2.7

* Add poyfill for Enumerable#filter_map
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index b426f9d5b..558a37f99 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -334,7 +334,7 @@ class Status < ApplicationRecord
     def from_text(text)
       return [] if text.blank?
 
-      text.scan(FetchLinkCardService::URL_PATTERN).map(&:first).uniq.map do |url|
+      text.scan(FetchLinkCardService::URL_PATTERN).map(&:first).uniq.filter_map do |url|
         status = begin
           if TagManager.instance.local_url?(url)
             ActivityPub::TagManager.instance.uri_to_resource(url, Status)
@@ -343,7 +343,7 @@ class Status < ApplicationRecord
           end
         end
         status&.distributable? ? status : nil
-      end.compact
+      end
     end
   end