diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-11 19:04:16 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-11 19:04:16 +0000 |
commit | 709e0ecbda73ec5b6b16ea07383e68f0a58fedc5 (patch) | |
tree | 01d2da1112ae28b9b431d7fe2b1e0a7926a16604 /lib/set.rb | |
parent | 5e868b2bcad572904e33ae6ff0198c6b5822128a (diff) |
set: speed up Set#include?
* lib/set.rb (initialize): internal hash defaults to false
* lib/set.rb (include?): use Hash#[] for optimized dispatch.
Patch by Ismael Abreu <[email protected]>
[ruby-core:67664] [Misc #10754]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/set.rb')
-rw-r--r-- | lib/set.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/set.rb b/lib/set.rb index f00cfac0c5..a3f185538f 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -78,7 +78,7 @@ class Set # If a block is given, the elements of enum are preprocessed by the # given block. def initialize(enum = nil, &block) # :yields: o - @hash ||= Hash.new + @hash ||= Hash.new(false) enum.nil? and return @@ -209,7 +209,7 @@ class Set # Returns true if the set contains the given object. def include?(o) - @hash.include?(o) + @hash[o] end alias member? include? |