Optimize map { ... }.compact calls (#15513)
* Optimize map { ... }.compact using Enumerable#filter_map, supported since Ruby 2.7 * Add poyfill for Enumerable#filter_map
This commit is contained in:
parent
9395143126
commit
087ed84367
22 changed files with 52 additions and 26 deletions
|
@ -508,7 +508,7 @@ class Account < ApplicationRecord
|
|||
def from_text(text)
|
||||
return [] if text.blank?
|
||||
|
||||
text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.map do |(username, domain)|
|
||||
text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.filter_map do |(username, domain)|
|
||||
domain = begin
|
||||
if TagManager.instance.local_domain?(domain)
|
||||
nil
|
||||
|
@ -517,7 +517,7 @@ class Account < ApplicationRecord
|
|||
end
|
||||
end
|
||||
EntityCache.instance.mention(username, domain)
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue