diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 17:03:15 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 17:03:15 -0800 |
commit | b8ed2d5ddff3db22430de983ba072f57b8aa3c00 (patch) | |
tree | d793a1105c50c53f7b62d84612f1cb1368faac12 /activerecord/lib/active_record | |
parent | 75e29e871e925cb7485cdbc283594d3d97871703 (diff) | |
download | rails-b8ed2d5ddff3db22430de983ba072f57b8aa3c00.tar.gz rails-b8ed2d5ddff3db22430de983ba072f57b8aa3c00.tar.bz2 rails-b8ed2d5ddff3db22430de983ba072f57b8aa3c00.zip |
return early in case the left or right side lists are empty
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 1254d68e9a..bd77aa30c1 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -359,11 +359,7 @@ module ActiveRecord reset end - if @target.any? - @target = merge_target_lists(targets, @target) - else - @target = targets - end + @target = merge_target_lists(targets, @target) end end @@ -441,6 +437,9 @@ module ActiveRecord private def merge_target_lists(loaded, existing) + return loaded if existing.empty? + return existing if loaded.empty? + loaded.map do |f| i = existing.index(f) if i |