diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-20 14:24:04 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-20 14:24:04 -0800 |
commit | 6e14feb978434802e7a46b26d99d64e31f545fe2 (patch) | |
tree | 653e7ddede519e26eac14683b5959732d6c9d1aa /activerecord | |
parent | 37b67df7e47966c88eaf5c6ed8c5286df69d20b9 (diff) | |
download | rails-6e14feb978434802e7a46b26d99d64e31f545fe2.tar.gz rails-6e14feb978434802e7a46b26d99d64e31f545fe2.tar.bz2 rails-6e14feb978434802e7a46b26d99d64e31f545fe2.zip |
use array arithmetic rather than create sets
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 18d05aa133..1c8541be67 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -344,12 +344,10 @@ module ActiveRecord other_array.each { |val| raise_on_type_mismatch(val) } load_target - other = other_array.size < 100 ? other_array : other_array.to_set - current = @target.size < 100 ? @target : @target.to_set transaction do - delete(@target.select { |v| !other.include?(v) }) - concat(other_array.select { |v| !current.include?(v) }) + delete(@target - other_array) + concat(other_array - @target) end end |