aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-16 13:34:18 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-16 13:34:18 -0800
commit59ba800698ac9dcea1df9e40bb03335ddb4f5156 (patch)
tree16ae4fc07b73bd20c797ba92032f2ec604ef475c /activerecord
parent7ebd36d1c4f958ceaf10cf7899936caeb173ac50 (diff)
downloadrails-59ba800698ac9dcea1df9e40bb03335ddb4f5156.tar.gz
rails-59ba800698ac9dcea1df9e40bb03335ddb4f5156.tar.bz2
rails-59ba800698ac9dcea1df9e40bb03335ddb4f5156.zip
refactoring uniq method
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 5b34ac907c..7cdd91e9b2 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -332,13 +332,10 @@ module ActiveRecord
end
def uniq(collection = self)
- seen = Set.new
- collection.map do |record|
- unless seen.include?(record.id)
- seen << record.id
- record
- end
- end.compact
+ seen = {}
+ collection.find_all do |record|
+ seen[record.id] = true unless seen.key?(record.id)
+ end
end
# Replace this collection with +other_array+