mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/set.rb (==): Optimization; patch by Arthur Schreiber [ruby-core:17203]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
242e2aaec2
commit
8ef3af646f
2 changed files with 14 additions and 7 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Sep 14 04:07:09 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/set.rb (==): Optimization; patch by Arthur Schreiber [ruby-core:17203]
|
||||
|
||||
Mon Sep 14 03:30:23 2009 Alexander Zavorine <alexandre.zavorine@nokia.com>
|
||||
|
||||
* symbian/pre-build: added rule to generate id.h for Symbian build.
|
||||
|
|
17
lib/set.rb
17
lib/set.rb
|
@ -327,13 +327,16 @@ class Set
|
|||
|
||||
# Returns true if two sets are equal. The equality of each couple
|
||||
# of elements is defined according to Object#eql?.
|
||||
def ==(set)
|
||||
equal?(set) and return true
|
||||
|
||||
set.is_a?(Set) && size == set.size or return false
|
||||
|
||||
hash = @hash.dup
|
||||
set.all? { |o| hash.include?(o) }
|
||||
def ==(other)
|
||||
if self.equal?(other)
|
||||
true
|
||||
elsif other.instance_of?(self.class)
|
||||
@hash == other.instance_variable_get(:@hash)
|
||||
elsif other.is_a?(Set) && self.size == other.size
|
||||
other.all? { |o| @hash.include?(o) }
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def hash # :nodoc:
|
||||
|
|
Loading…
Add table
Reference in a new issue