Memoize recursive dependency checks; reduces calls to 'f.recursive_dependencies' by an order of magnitude

This commit is contained in:
richiethomas
2017-10-17 20:52:18 -04:00
parent 9ef82ae1e2
commit dfaaada8b6
+4
View File
@@ -54,11 +54,14 @@ module Homebrew
end
ignores << "recommended?" if ARGV.include? "--skip-recommended"
memo = {}
uses = formulae.select do |f|
used_formulae.all? do |ff|
begin
if recursive
deps = f.recursive_dependencies do |dependent, dep|
memo_key = [dependent, dep].to_s
next if memo[memo_key]
if dep.recommended?
Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
elsif dep.optional?
@@ -72,6 +75,7 @@ module Homebrew
if dep.is_a?(TapDependency) && !dep.tap.installed?
Dependency.keep_but_prune_recursive_deps
end
memo[memo_key] = true
end
dep_formulae = deps.flat_map do |dep|