From 6e14feb978434802e7a46b26d99d64e31f545fe2 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 20 Dec 2010 14:24:04 -0800 Subject: use array arithmetic rather than create sets --- .../lib/active_record/associations/association_collection.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/associations') 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 -- cgit v1.2.3