summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/spec_set.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 0dfaed9807..85a9d1537b 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -12,15 +12,17 @@ module Bundler
end
def for(dependencies, check = false, match_current_platform = false)
- handled = []
+ # dep.name => [list, of, deps]
+ handled = Hash.new {|h, k| h[k] = [] }
deps = dependencies.dup
specs = []
loop do
break unless dep = deps.shift
- next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
+ next if handled[dep.name].any? {|d| match_current_platform || d.__platform == dep.__platform } || dep.name == "bundler"
- handled << dep
+ # use a hash here to ensure constant lookup time in the `any?` call above
+ handled[dep.name] << dep
specs_for_dep = spec_for_dependency(dep, match_current_platform)
if specs_for_dep.any?