SIGN IN SIGN UP
Homebrew / brew UNCLAIMED

🍺 The missing package manager for macOS (or Linux)

0 0 185 Ruby

perf: avoid Formulary.resolve per dep in autoremove/cleanup/doctor

autoremove / cleanup
--------------------
bottled_formulae_with_no_formula_dependents: replace
installed_runtime_formula_dependencies with direct tab data reads.
Build a Set of dep base names from tab.runtime_dependencies hashes
instead of resolving each dep via Formulary.resolve. Fallback kept for
pre-1.1.6 installations.

Rename formulae_with_cask_dependents to cask_dependent_formula_names,
returning T::Set[String] instead of T::Array[Formula]. Look up cask
formula deps by name in the already-loaded formulae array (O(1) hash)
instead of calling Formulary.resolve. Same tab-data path for transitive
deps.

brew autoremove --dry-run: 3.68s -> 1.65s (~55% faster)
brew cleanup --dry-run:    7.39s -> 5.72s (~23% faster)

brew doctor (check_missing_deps)
---------------------------------
missing_dependencies called dep.to_installed_formula.installed_prefixes.none?
for every runtime dep of every installed formula, triggering
Formulary.resolve per dep.

Replace with (HOMEBREW_CELLAR/base_name).directory? — a single
filesystem stat. Also extract base_name before the hide check, fixing a
pre-existing bug where tapnamed deps (e.g. "homebrew/core/wget") could
not be matched by base-name hide lists.

check_missing_deps:  0.95s -> 0.06s (~15x faster)
brew doctor overall: 6.24s -> 5.51s (~12% faster)

check_deprecated_disabled
--------------------------
Combine two Formula.installed.select calls into one pass.

Tests
-----
- formula_spec: add describe "#missing_dependencies" covering no tab
  data, installed dep, missing dep, hidden dep (even when installed),
  and tapnamed dep matched by base-name hide list (the bug-fix case).
- autoremove_spec: add context for when tab.runtime_dependencies returns
  actual hashes, asserting installed_runtime_formula_dependencies is not
  called (exercises the new fast path rather than only the nil fallback).
D
Douglas Eichelberger committed
1e8f1eeb0366f0ded2b062e8df4402b3fc3c6d3f
Parent: aad0a5c