mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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 <ismaelga@gmail.com> [ruby-core:67664] [Misc #10754] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5e868b2bca
commit
709e0ecbda
2 changed files with 10 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Thu Feb 12 03:28:05 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* lib/set.rb (initialize): internal hash defaults to false
|
||||
|
||||
* lib/set.rb (include?): use Hash#[] for optimized dispatch.
|
||||
Patch by Ismael Abreu <ismaelga@gmail.com>
|
||||
[ruby-core:67664] [Misc #10754]
|
||||
|
||||
Wed Feb 11 11:09:52 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/digest/digest_conf.rb (digest_conf): check for CommonDigest.
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
Loading…
Reference in a new issue