aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorXu Cheng2015-06-21 16:42:52 +0800
committerXu Cheng2015-06-22 21:24:50 +0800
commitb36317540180957a97c9b40cd8f1e4bc647cb7b2 (patch)
tree518fa1a8a63990886f354e673d9d9c01dd50dc5e /Library/Homebrew
parentf1bf81dd55928464a654b84d171e191b0438a5f1 (diff)
downloadbrew-b36317540180957a97c9b40cd8f1e4bc647cb7b2.tar.bz2
improve audit_formula_name performance
Closes Homebrew/homebrew#40939. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cmd/audit.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index b2211fdc1..a583f3bbf 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -205,6 +205,11 @@ class FormulaAuditor
end
@@aliases ||= Formula.aliases
+ @@remote_official_taps ||= if (homebrew_tapd = HOMEBREW_LIBRARY/"Taps/homebrew").directory?
+ OFFICIAL_TAPS - homebrew_tapd.subdirs.map(&:basename).map { |tap| tap.to_s.sub(/^homebrew-/, "") }
+ else
+ OFFICIAL_TAPS
+ end
def audit_formula_name
return unless @strict
@@ -224,14 +229,11 @@ class FormulaAuditor
return
end
- same_name_tap_formulae = Formula.tap_names.select { |f| f =~ %r{^homebrew/[^/]+/#{name}$} }
- homebrew_tapd = HOMEBREW_LIBRARY/"Taps/homebrew"
- current_taps = if homebrew_tapd.directory?
- homebrew_tapd.subdirs.map(&:basename).map { |tap| tap.to_s.sub(/^homebrew-/, "") }
- else
- []
+ same_name_tap_formulae = Formula.tap_names.select do |tap_formula_name|
+ user_name, _, formula_name = tap_formula_name.split("/", 3)
+ user_name == "homebrew" && formula_name == name
end
- same_name_tap_formulae += (OFFICIAL_TAPS - current_taps).map do |tap|
+ same_name_tap_formulae += @@remote_official_taps.map do |tap|
Thread.new { Homebrew.search_tap "homebrew", tap, name }
end.map(&:value).flatten
same_name_tap_formulae.delete(full_name)