Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reduce calls to owners_by_key and to read_attribute, respond_to? etc

  • Loading branch information...
commit 441d8ec13037c90b448769178fb8c3fef40fb74b 1 parent b31ce90
Aaron Patterson tenderlove authored
5 activerecord/lib/active_record/associations/preloader/association.rb
View
@@ -68,7 +68,8 @@ def options
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 @@ def associated_records_by_owner
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
Please sign in to comment.
Something went wrong with that request. Please try again.