tap: memoize Tap.reverse_tap_migrations_renames

This should be a relatively small hash but it gets recalculated
every time we call Cask#oldnames or Formula#oldnames which ends
up being a lot if you run certain commands with --eval-all.

For example, when running the following, it took 10% of the total
runtime.

```
brew deps --casks --eval-all
```
This commit is contained in:
apainintheneck 2024-03-01 19:57:13 -08:00
parent 99d5200db3
commit 2da1c93df7

View File

@ -820,7 +820,7 @@ class Tap
sig { returns(T::Hash[String, T::Array[String]]) }
def self.reverse_tap_migrations_renames
Tap.each_with_object({}) do |tap, hash|
cache[:reverse_tap_migrations_renames] ||= Tap.each_with_object({}) do |tap, hash|
tap.tap_migrations.each do |old_name, new_name|
new_tap_user, new_tap_repo, new_name = new_name.split("/", 3)
next unless new_name