Permalink
Browse files

reduce calls to owners_by_key and to read_attribute, respond_to? etc

  • Loading branch information...
1 parent b31ce90 commit 441d8ec13037c90b448769178fb8c3fef40fb74b @tenderlove tenderlove committed Jul 1, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 activerecord/lib/active_record/associations/preloader/association.rb
@@ -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

0 comments on commit 441d8ec

Please sign in to comment.