tap: optimise CoreTap#formula_files_by_name
This commit is contained in:
parent
78b7d7e2d6
commit
b1ddb056db
@ -1138,12 +1138,13 @@ 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?
|
||||||
|
|
||||||
|
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
|
||||||
# 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]
|
||||||
new_path = path/formula_hash["ruby_source_path"]
|
new_path = File.join(tap_path, formula_hash["ruby_source_path"]) # Pathname equivalent is slow in a tight loop
|
||||||
hash[name] = new_path if existing_path.nil? || existing_path.to_s.length < new_path.to_s.length
|
hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user