mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use Enumerable#all? to optimize a bit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d29143b99e
commit
e1488bd243
1 changed files with 2 additions and 5 deletions
|
@ -263,8 +263,7 @@ class Set
|
|||
|
||||
def contain?(enum)
|
||||
enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
|
||||
enum.each { |o| include?(o) or return false }
|
||||
true
|
||||
enum.all? { |o| include?(o) }
|
||||
end
|
||||
|
||||
def each
|
||||
|
@ -338,9 +337,7 @@ class Set
|
|||
|
||||
set.is_a?(Set) && size == set.size or return false
|
||||
|
||||
set.each { |o| include?(o) or return false }
|
||||
|
||||
true
|
||||
set.all? { |o| include?(o) }
|
||||
end
|
||||
|
||||
def hash
|
||||
|
|
Loading…
Add table
Reference in a new issue