-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor method to remove extra tap requires #18010
Refactor method to remove extra tap requires #18010
Conversation
We were selectively requiring the tap.rb file in a few places for performance reasons. The main method we were referencing was the `Tap.cmd_directories` method which uses `Pathname` and the `TAP_DIRECTORY` constant internally. `Tap.cmd_directories` is mostly used in the `Commands` module and that is loaded very early on in the program so it made sense to move that command to that module. To facilitate that I moved the `TAP_DIRECTORY` constant to the top-level and renamed it to `HOMEBREW_TAP_DIRECTORY`. It now lies in the tap_constants.rb file. A nice bonus of this refactor is that it speeds up loading external commands since the tap.rb file is no longer required by default in those cases.
- Move HOMEBREW_TAP_DIRECTORY to startup/config.rb because this file holds more of the directory constants - Rename `Commands.cmd_directories` to `Commands.tap_cmd_directories` to better express that the commands come from taps This file has the directory constants while the other one has regexes. Just better organization.
To recap the main changes here are now:
I checked that the old names aren't referenced in any of the core taps I have installed locally.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, wonderful work @apainintheneck 👏🏻.
Given how often these require changes sadly go 💥: let's hold off until after the next tag (which will be later today UK time, merge Tuesday UK time?)
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?We were selectively requiring the tap.rb file in a few places for performance reasons. The main method we were referencing was the
Tap.cmd_directories
method which usesPathname
and theTAP_DIRECTORY
constant internally.Tap.cmd_directories
is mostly used in theCommands
module and that is loaded very early on in the program so it made sense to move that command to that module. To facilitate that I moved theTAP_DIRECTORY
constant to the top-level and renamed it toHOMEBREW_TAP_DIRECTORY
. It now lies in the tap_constants.rb file.A nice bonus of this refactor is that it speeds up loading external commands since the tap.rb file is no longer required by default in those cases.
brew commands
also gets a speed boost sinceCommands.commands
no longer requires tap.rb.Note: All benchmarks are on an old iMac so may not be as noticeable on newer machines.
Risks: It's possible that another file was counting on the inclusion of tap.rb somewhere else in the codebase and this causes a missing require error. We have no easy way to test for that that I'm aware of.