diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-07-01 09:55:31 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-07-01 09:55:48 -0700 |
commit | 441d8ec13037c90b448769178fb8c3fef40fb74b (patch) | |
tree | 7aaafeb160a478d3a4f0719f7c8cbe2de7eba12c /activerecord/lib/active_record | |
parent | b31ce90e99ca73ebbe529d9fef9d6ead3e2364a9 (diff) | |
download | rails-441d8ec13037c90b448769178fb8c3fef40fb74b.tar.gz rails-441d8ec13037c90b448769178fb8c3fef40fb74b.tar.bz2 rails-441d8ec13037c90b448769178fb8c3fef40fb74b.zip |
reduce calls to owners_by_key and to read_attribute, respond_to? etc
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 7256dd5288..779f8164cc 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -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 |