diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-25 10:46:08 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-25 10:46:08 -0700 |
commit | 71408911750ed7101f96bbe8a94ce06757052273 (patch) | |
tree | 11ef56155b463ce5aa63dd93c00b522ad368e613 /activerecord | |
parent | 57112fb7e7cb72584010b0957dfce91e0fc80a12 (diff) | |
download | rails-71408911750ed7101f96bbe8a94ce06757052273.tar.gz rails-71408911750ed7101f96bbe8a94ce06757052273.tar.bz2 rails-71408911750ed7101f96bbe8a94ce06757052273.zip |
hash insertion order doesn't matter anymore, so only loop over the
owners once
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index bd63b40472..69b65982b3 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -73,7 +73,7 @@ module ActiveRecord owner_keys = owners_map.keys.compact # Each record may have multiple owners, and vice-versa - records_by_owner = Hash.new do |h,owner| + records_by_owner = owners.each_with_object({}) do |owner,h| h[owner] = [] end @@ -90,9 +90,7 @@ module ActiveRecord end end - owners.each_with_object(records_by_owner) do |owner,h| - h[owner] ||= [] - end + records_by_owner end def load_slices(slices) |