summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-05-15 22:24:54 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-06-02 16:51:13 -0500
commitfaaeccf2e0b06ed76dcb669ce309c8ab750b62c3 (patch)
tree886b968a2a1374992fb22d53c511214d5290250e
parent667d4e4487bde5196bb326a7c03531e65de85cf6 (diff)
downloadbundler-faaeccf2e0b06ed76dcb669ce309c8ab750b62c3.tar.gz
[Index] Speed up searching
This is a two-fold improvement: 1) using full_name as the lookup is much faster than a custom array 2) using add? avoids a second set lookup
-rw-r--r--lib/bundler/index.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index 5c49034280..5cee0c7ea7 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -60,14 +60,12 @@ module Bundler
# about, returning all of the results.
def search(query, base = nil)
results = local_search(query, base)
- seen = Set.new(results.map {|spec| [spec.name, spec.version, spec.platform] })
+ seen = results.map(&:full_name).to_set
@sources.each do |source|
source.search(query, base).each do |spec|
- lookup = [spec.name, spec.version, spec.platform]
- unless seen.include?(lookup)
+ if seen.add?(spec.full_name)
results << spec
- seen << lookup
end
end
end