Remove intermediary arrays when creating hash maps from results (#9291)
This commit is contained in:
parent
367ad21995
commit
8069fd636b
11 changed files with 20 additions and 20 deletions
|
@ -21,7 +21,7 @@ class EntityCache
|
|||
end
|
||||
|
||||
unless uncached_ids.empty?
|
||||
uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).map { |item| [item.shortcode, item] }.to_h
|
||||
uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).each_with_object({}) { |item, h| h[item.shortcode] = item }
|
||||
uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
||||
end
|
||||
|
||||
|
|
|
@ -128,9 +128,9 @@ class Formatter
|
|||
return html if emojis.empty?
|
||||
|
||||
emoji_map = if animate
|
||||
emojis.map { |e| [e.shortcode, full_asset_url(e.image.url)] }.to_h
|
||||
emojis.each_with_object({}) { |e, h| h[e.shortcode] = full_asset_url(e.image.url) }
|
||||
else
|
||||
emojis.map { |e| [e.shortcode, full_asset_url(e.image.url(:static))] }.to_h
|
||||
emojis.each_with_object({}) { |e, h| h[e.shortcode] = full_asset_url(e.image.url(:static)) }
|
||||
end
|
||||
|
||||
i = -1
|
||||
|
|
|
@ -31,7 +31,7 @@ module Settings
|
|||
|
||||
def all_as_records
|
||||
vars = thing_scoped
|
||||
records = vars.map { |r| [r.var, r] }.to_h
|
||||
records = vars.each_with_object({}) { |r, h| h[r.var] = r }
|
||||
|
||||
Setting.default_settings.each do |key, default_value|
|
||||
next if records.key?(key) || default_value.is_a?(Hash)
|
||||
|
@ -65,7 +65,7 @@ module Settings
|
|||
|
||||
class << self
|
||||
def default_settings
|
||||
defaulting = DEFAULTING_TO_UNSCOPED.map { |k| [k, Setting[k]] }.to_h
|
||||
defaulting = DEFAULTING_TO_UNSCOPED.each_with_object({}) { |k, h| h[k] = Setting[k] }
|
||||
Setting.default_settings.merge!(defaulting)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue