Skip to content
This repository
Browse code

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

owners once
  • Loading branch information...
commit 71408911750ed7101f96bbe8a94ce06757052273 1 parent 57112fb
Aaron Patterson tenderlove authored
6 activerecord/lib/active_record/associations/preloader/association.rb
@@ -73,7 +73,7 @@ def associated_records_by_owner(preloader)
73 73 owner_keys = owners_map.keys.compact
74 74
75 75 # Each record may have multiple owners, and vice-versa
76   - records_by_owner = Hash.new do |h,owner|
  76 + records_by_owner = owners.each_with_object({}) do |owner,h|
77 77 h[owner] = []
78 78 end
79 79
@@ -90,9 +90,7 @@ def associated_records_by_owner(preloader)
90 90 end
91 91 end
92 92
93   - owners.each_with_object(records_by_owner) do |owner,h|
94   - h[owner] ||= []
95   - end
  93 + records_by_owner
96 94 end
97 95
98 96 def load_slices(slices)

0 comments on commit 7140891

Please sign in to comment.
Something went wrong with that request. Please try again.