mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
reduce calls to owners_by_key and to read_attribute, respond_to? etc
This commit is contained in:
parent
b31ce90e99
commit
441d8ec130
1 changed files with 3 additions and 2 deletions
|
@ -68,7 +68,8 @@ module ActiveRecord
|
|||
private
|
||||
|
||||
def associated_records_by_owner
|
||||
owner_keys = owners.map { |owner| owner[owner_key_name] }.compact.uniq
|
||||
owners_map = owners_by_key
|
||||
owner_keys = owners_map.keys.compact
|
||||
|
||||
if klass.nil? || owner_keys.empty?
|
||||
records = []
|
||||
|
@ -84,7 +85,7 @@ module ActiveRecord
|
|||
records.each do |record|
|
||||
owner_key = record[association_key_name].to_s
|
||||
|
||||
owners_by_key[owner_key].each do |owner|
|
||||
owners_map[owner_key].each do |owner|
|
||||
records_by_owner[owner] << record
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue