SIGN IN SIGN UP
Homebrew / brew UNCLAIMED

🍺 The missing package manager for macOS (or Linux)

0 0 185 Ruby

formula: use Pathname#empty? instead of children.empty? to check for installation

`Pathname#children.empty?` reads all directory entries into a Ruby Array
just to check whether any exist. `Pathname#empty?` (backed by
`Dir.empty?`) stops at the first entry, avoiding the full enumeration.

Microbenchmark (100,000 iterations, 11-entry Cellar keg directory):
  dir.children.empty? : 3084ms
  dir.empty?          : 2136ms (~1.44x faster)

`Formula#latest_version_installed?` and the prefix-installed check in
install.rb are called for every formula when commands like
`brew deps --installed` enumerate installed formulae, so the savings
compound across the full set.
D
Douglas Eichelberger committed
301664341843ae17fff0c0c4713aece01cfc7731
Parent: c997366