diff options
author | Smit Shah <who828@gmail.com> | 2014-04-15 10:07:04 +0530 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2014-06-15 22:24:49 -0700 |
commit | 573f8eb6d63f38df2d80d322656fe00e80691b1d (patch) | |
tree | 1b5965c228666f0c059112ab892fb06c63b7c5d0 | |
parent | bde22ac685e363b08d2095fc32de346617e9fa4e (diff) | |
download | bundler-573f8eb6d63f38df2d80d322656fe00e80691b1d.tar.gz |
Improved performance of Definition
1) Improved finding locked_deps efficiency in coverage_local_specs
from O(N^2) to O(N).
2) Improved specs_changed from O(N^2) to O(N)
-rw-r--r-- | lib/bundler/definition.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 94a4d6d507..17474143e5 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -412,10 +412,8 @@ module Bundler locked = @locked_sources.find(&block) if locked - unlocking = locked.specs.any? do |spec| - @locked_specs.any? do |locked_spec| - locked_spec.source != locked - end + unlocking = @locked_specs.any? do |locked_spec| + locked_spec.source != locked end end @@ -508,8 +506,9 @@ module Bundler # and Gemfile.lock. If the Gemfile modified a dependency, but # the gem in the Gemfile.lock still satisfies it, this is fine # too. + locked_deps_hash = @locked_deps.each_with_object({}) { |dep, hsh| hsh[dep] = dep } @dependencies.each do |dep| - locked_dep = @locked_deps.find { |d| dep == d } + locked_dep = locked_deps_hash[dep] if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) deps << dep |