зеркало из https://github.com/github/ruby.git
Hash instead of Set
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
583d903c2b
Коммит
89e82a75a8
|
@ -214,12 +214,11 @@ module IRB
|
||||||
# We could cache the result, but this is very fast already.
|
# We could cache the result, but this is very fast already.
|
||||||
# By using this approach, we avoid Module#name calls, which are
|
# By using this approach, we avoid Module#name calls, which are
|
||||||
# relatively slow when there are a lot of anonymous modules defined.
|
# relatively slow when there are a lot of anonymous modules defined.
|
||||||
require 'set'
|
s = {}
|
||||||
s = Set.new
|
|
||||||
|
|
||||||
scanner = lambda do |m|
|
scanner = lambda do |m|
|
||||||
next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
|
next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
|
||||||
s << m
|
s[m] = true
|
||||||
m.constants(false).each do |c|
|
m.constants(false).each do |c|
|
||||||
value = m.const_get(c)
|
value = m.const_get(c)
|
||||||
scanner.call(value) if value.is_a?(Module)
|
scanner.call(value) if value.is_a?(Module)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче