Permalink
Browse files

hash insertion order doesn't matter anymore, so only loop over the

owners once
  • Loading branch information...
1 parent 57112fb commit 71408911750ed7101f96bbe8a94ce06757052273 @tenderlove tenderlove committed Sep 25, 2013
Showing with 2 additions and 4 deletions.
  1. +2 −4 activerecord/lib/active_record/associations/preloader/association.rb
View
6 activerecord/lib/active_record/associations/preloader/association.rb
@@ -73,7 +73,7 @@ def associated_records_by_owner(preloader)
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 @@ def associated_records_by_owner(preloader)
end
end
- owners.each_with_object(records_by_owner) do |owner,h|
- h[owner] ||= []
- end
+ records_by_owner
end
def load_slices(slices)

0 comments on commit 7140891

Please sign in to comment.