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
|
@ -29,7 +29,7 @@ class EntityCache
|
|||
uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
||||
end
|
||||
|
||||
shortcodes.map { |shortcode| cached[to_key(:emoji, shortcode, domain)] || uncached[shortcode] }.compact
|
||||
shortcodes.filter_map { |shortcode| cached[to_key(:emoji, shortcode, domain)] || uncached[shortcode] }
|
||||
end
|
||||
|
||||
def to_key(type, *ids)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue