diff options
| author | richiethomas | 2017-10-13 19:33:45 -0400 |
|---|---|---|
| committer | richiethomas | 2017-10-17 20:52:18 -0400 |
| commit | dfaaada8b6cf09fde47810c9dff79b8165b07ca0 (patch) | |
| tree | 186b87d88046cf63ea99ebf6ca930c5f4c4dd0a5 /Library | |
| parent | 9ef82ae1e254088e9232ba7e67afa0da9246bc6c (diff) | |
| download | brew-dfaaada8b6cf09fde47810c9dff79b8165b07ca0.tar.bz2 | |
Memoize recursive dependency checks; reduces calls to 'f.recursive_dependencies' by an order of magnitude
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/uses.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index 0b09e1bf1..5b6319cdc 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -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| |
