Merge pull request #16791 from Homebrew/fix-perfomance-regression-in-tap-files_by_name
tap: fix performance regression in *_files_by_name
This commit is contained in:
commit
4e65af0391
@ -820,7 +820,7 @@ class Tap
|
|||||||
|
|
||||||
sig { returns(T::Hash[String, T::Array[String]]) }
|
sig { returns(T::Hash[String, T::Array[String]]) }
|
||||||
def self.reverse_tap_migrations_renames
|
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|
|
tap.tap_migrations.each do |old_name, new_name|
|
||||||
new_tap_user, new_tap_repo, new_name = new_name.split("/", 3)
|
new_tap_user, new_tap_repo, new_name = new_name.split("/", 3)
|
||||||
next unless new_name
|
next unless new_name
|
||||||
@ -1211,6 +1211,7 @@ class CoreTap < AbstractCoreTap
|
|||||||
def formula_files_by_name
|
def formula_files_by_name
|
||||||
return super if Homebrew::EnvConfig.no_install_from_api?
|
return super if Homebrew::EnvConfig.no_install_from_api?
|
||||||
|
|
||||||
|
@formula_files_by_name ||= begin
|
||||||
tap_path = path.to_s
|
tap_path = path.to_s
|
||||||
Homebrew::API::Formula.all_formulae.each_with_object({}) do |item, hash|
|
Homebrew::API::Formula.all_formulae.each_with_object({}) do |item, hash|
|
||||||
name, formula_hash = item
|
name, formula_hash = item
|
||||||
@ -1221,6 +1222,7 @@ class CoreTap < AbstractCoreTap
|
|||||||
hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length
|
hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sig { returns(T::Hash[String, T.untyped]) }
|
sig { returns(T::Hash[String, T.untyped]) }
|
||||||
def to_api_hash
|
def to_api_hash
|
||||||
@ -1279,7 +1281,7 @@ class CoreCaskTap < AbstractCoreTap
|
|||||||
def cask_files_by_name
|
def cask_files_by_name
|
||||||
return super if Homebrew::EnvConfig.no_install_from_api?
|
return super if Homebrew::EnvConfig.no_install_from_api?
|
||||||
|
|
||||||
Homebrew::API::Cask.all_casks.each_with_object({}) do |item, hash|
|
@cask_files_by_name ||= Homebrew::API::Cask.all_casks.each_with_object({}) do |item, hash|
|
||||||
name, cask_hash = item
|
name, cask_hash = item
|
||||||
# If there's more than one item with the same path: use the longer one to prioritise more specific results.
|
# If there's more than one item with the same path: use the longer one to prioritise more specific results.
|
||||||
existing_path = hash[name]
|
existing_path = hash[name]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user