summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert <robert@jazzonmymind.xyz>2017-06-03 15:30:59 +0100
committerrobert <robert@jazzonmymind.xyz>2017-06-03 15:30:59 +0100
commitfa67de2f98c3ef00295ebc4ec84b3441d17afa72 (patch)
tree6ef3f2ed65c444030b5426dc40479d59e50dd257
parent477429078a7123dbf8a2eb4d00b9e623051475c6 (diff)
downloadpry-fa67de2f98c3ef00295ebc4ec84b3441d17afa72.tar.gz
use Set instead of Array.
The tests are a bit faster, before this change i ran the tests 10 times: ["5.49", "5.56", "5.53", "5.27", "5.26", "5.24", "5.48", "5.19", "5.28"] After this change i ran them again: ["5.02", "5.25", "4.85", "4.97", "4.9", "4.86", "4.83", "4.87", "4.86"]
-rw-r--r--lib/pry/input_completer.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/pry/input_completer.rb b/lib/pry/input_completer.rb
index 743cab8e..859cb667 100644
--- a/lib/pry/input_completer.rb
+++ b/lib/pry/input_completer.rb
@@ -167,21 +167,18 @@ class Pry::InputCompleter
end
else
# func1.func2
- candidates = []
+ candidates = Set.new
to_ignore = ignored_modules
ObjectSpace.each_object(Module){|m|
next if (to_ignore.include?(m) rescue true)
-
# jruby doesn't always provide #instance_methods() on each
# object.
if m.respond_to?(:instance_methods)
- candidates.concat m.instance_methods(false).collect(&:to_s)
+ candidates.merge m.instance_methods(false).collect(&:to_s)
end
}
- candidates.uniq!
- candidates.sort!
end
- select_message(path, receiver, message, candidates)
+ select_message(path, receiver, message, candidates.sort)
when /^\.([^.]*)$/
# Unknown(maybe String)
receiver = ""