This is yet another approach to f3a5a3c449cf004aee662966e6c8dd2ebe122c0f
which got merged in over the weekend. It is much simpler than what we've
got now with almost exactly the same performance characteristics. A great
combination of maintability and performance.
```console
$ hyperfine --parameter-list branch master,speed-up-loading-cask-and-formula-file-names_v4 --warmup 5 --setup 'git switch {branch}' 'brew cat gimp'
Benchmark 1: brew cat gimp (branch = master)
Time (mean ± σ): 1.459 s ± 0.012 s [User: 0.892 s, System: 0.536 s]
Range (min … max): 1.448 s … 1.483 s 10 runs
Benchmark 2: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v4)
Time (mean ± σ): 1.456 s ± 0.009 s [User: 0.889 s, System: 0.536 s]
Range (min … max): 1.445 s … 1.468 s 10 runs
Summary
brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v4) ran
1.00 ± 0.01 times faster than brew cat gimp (branch = master)
```
Currently, ruby files that are not in the Cask directory are
considered to be formulae if a Formula or HomebrewFormula directory
doesn't exist which doesn't make sense. We know that these should
only be in a few directories so we can check for that explicitly.
Beyond that the `Tap#cask_file?` and `Tap.formula_file?` methods
were only used inside update-report so it doesn't make sense to
turn them into pathnames and expand things when we know that
each string will be a relative path from a tap that we can just
check with a regex.
This change will stop other tap changes like new commands or
changes to other directories like lib/ from showing up as new formulae.
I tried opening a PR for this a long time ago but I got busy
with other things and it got closed by the stale bot.
- https://github.com/Homebrew/brew/pull/15489
`brew test-bot` can occasionally spend a long time doing nothing when
testing dependents.[^1] This is because it takes a long time to work out
that there is nothing to do.
To fix this, let's adjust `brew determine-test-runners` to pass on only
the list of formulae for which there is work to be done so that
`brew test-bot` doesn't need to waste time working this out.
[^1]: For example, it spends about 15 minutes doing nothing at https://github.com/Homebrew/homebrew-core/actions/runs/10500178069/job/29133091332?pr=180185
These are slow because of some Pathname related reasons so it's been
changed up to use `Dir.glob` instead and that makes a large difference.
```
$ hyperfine --parameter-list branch master,speed-up-loading-cask-and-formula-file-names,speed-up-loading-cask-and-formula-file-names_v2 --warmup 5 --setup 'git switch {branch}' 'brew cat gimp'
Benchmark 1: brew cat gimp (branch = master)
Time (mean ± σ): 2.150 s ± 0.014 s [User: 1.369 s, System: 0.745 s]
Range (min … max): 2.126 s … 2.174 s 10 runs
Benchmark 2: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names)
Time (mean ± σ): 1.814 s ± 0.012 s [User: 1.068 s, System: 0.711 s]
Range (min … max): 1.797 s … 1.840 s 10 runs
Benchmark 3: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v2)
Time (mean ± σ): 1.489 s ± 0.009 s [User: 0.905 s, System: 0.550 s]
Range (min … max): 1.478 s … 1.503 s 10 runs
Summary
brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v2) ran
1.22 ± 0.01 times faster than brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names)
1.44 ± 0.01 times faster than brew cat gimp (branch = master)
```