aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorXu Cheng2015-09-27 16:52:14 +0800
committerXu Cheng2015-09-30 16:25:30 +0800
commit3b520cf195b6d766d134a1f2bd033347c714a143 (patch)
tree31001ad53b1fcad563994aa328f82c59a7a805d8 /Library/Homebrew/cmd
parent6240e896b2b3405dd3ffdf892b60e5eed05707b1 (diff)
downloadbrew-3b520cf195b6d766d134a1f2bd033347c714a143.tar.bz2
cache taps
There are plenty of IO operations inside Tap object, and it will be more when implementing formula alias reverse look up(e.g. list all of alias names for a formula). So let's cache them. Some benchmark: $ time brew info $(brew ruby -e 'puts Formula.tap_names') > /dev/null Before: 6.40s user 2.42s system 96% cpu 9.134 total After: 4.75s user 0.77s system 97% cpu 5.637 total Closes Homebrew/homebrew#44377. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/info.rb2
-rw-r--r--Library/Homebrew/cmd/readall.rb2
-rw-r--r--Library/Homebrew/cmd/tap-info.rb2
-rw-r--r--Library/Homebrew/cmd/tap-pin.rb2
-rw-r--r--Library/Homebrew/cmd/tap-unpin.rb2
-rw-r--r--Library/Homebrew/cmd/tap.rb2
-rw-r--r--Library/Homebrew/cmd/test-bot.rb6
-rw-r--r--Library/Homebrew/cmd/untap.rb2
-rw-r--r--Library/Homebrew/cmd/update.rb4
9 files changed, 13 insertions, 11 deletions
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index a2b491e05..52d39ca15 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -69,7 +69,7 @@ module Homebrew
def github_info(f)
if f.tap?
user, repo = f.tap.split("/", 2)
- tap = Tap.new user, repo.gsub(/^homebrew-/, "")
+ tap = Tap.fetch user, repo.gsub(/^homebrew-/, "")
if remote = tap.remote
path = f.path.relative_path_from(tap.path)
github_remote_path(remote, path)
diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb
index 81eaba37d..5e87fcbdb 100644
--- a/Library/Homebrew/cmd/readall.rb
+++ b/Library/Homebrew/cmd/readall.rb
@@ -46,7 +46,7 @@ module Homebrew
if ARGV.named.empty?
formulae = Formula.files
else
- tap = Tap.new(*tap_args)
+ tap = Tap.fetch(*tap_args)
raise TapUnavailableError, tap.name unless tap.installed?
formulae = tap.formula_files
end
diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb
index 1354264df..dc979af7e 100644
--- a/Library/Homebrew/cmd/tap-info.rb
+++ b/Library/Homebrew/cmd/tap-info.rb
@@ -6,7 +6,7 @@ module Homebrew
taps = Tap
else
taps = ARGV.named.map do |name|
- Tap.new(*tap_args(name))
+ Tap.fetch(*tap_args(name))
end
end
diff --git a/Library/Homebrew/cmd/tap-pin.rb b/Library/Homebrew/cmd/tap-pin.rb
index 40888428a..80f1f762a 100644
--- a/Library/Homebrew/cmd/tap-pin.rb
+++ b/Library/Homebrew/cmd/tap-pin.rb
@@ -3,7 +3,7 @@ require "cmd/tap"
module Homebrew
def tap_pin
ARGV.named.each do |name|
- tap = Tap.new(*tap_args(name))
+ tap = Tap.fetch(*tap_args(name))
tap.pin
ohai "Pinned #{tap.name}"
end
diff --git a/Library/Homebrew/cmd/tap-unpin.rb b/Library/Homebrew/cmd/tap-unpin.rb
index 4462ce68d..641b7c945 100644
--- a/Library/Homebrew/cmd/tap-unpin.rb
+++ b/Library/Homebrew/cmd/tap-unpin.rb
@@ -3,7 +3,7 @@ require "cmd/tap"
module Homebrew
def tap_unpin
ARGV.named.each do |name|
- tap = Tap.new(*tap_args(name))
+ tap = Tap.fetch(*tap_args(name))
tap.unpin
ohai "Unpinned #{tap.name}"
end
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb
index 291407aff..294106b3c 100644
--- a/Library/Homebrew/cmd/tap.rb
+++ b/Library/Homebrew/cmd/tap.rb
@@ -23,7 +23,7 @@ module Homebrew
# ensure git is installed
Utils.ensure_git_installed!
- tap = Tap.new user, repo
+ tap = Tap.fetch user, repo
return false if tap.installed?
ohai "Tapping #{tap}"
remote = clone_target || "https://github.com/#{tap.user}/homebrew-#{tap.repo}"
diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb
index 66f23d873..658f042f9 100644
--- a/Library/Homebrew/cmd/test-bot.rb
+++ b/Library/Homebrew/cmd/test-bot.rb
@@ -39,20 +39,20 @@ module Homebrew
def resolve_test_tap
tap = ARGV.value("tap")
- return Tap.new(*tap_args(tap)) if tap
+ return Tap.fetch(*tap_args(tap)) if tap
if ENV["UPSTREAM_BOT_PARAMS"]
bot_argv = ENV["UPSTREAM_BOT_PARAMS"].split " "
bot_argv.extend HomebrewArgvExtension
tap = bot_argv.value("tap")
- return Tap.new(*tap_args(tap)) if tap
+ return Tap.fetch(*tap_args(tap)) if tap
end
if git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
# Also can get tap from Jenkins GIT_URL.
url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/")
HOMEBREW_TAP_ARGS_REGEX =~ url_path
- return Tap.new($1, $3) if $1 && $3 && $3 != "homebrew"
+ return Tap.fetch($1, $3) if $1 && $3 && $3 != "homebrew"
end
# return nil means we are testing core repo.
diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb
index 22dab7383..c70a0d007 100644
--- a/Library/Homebrew/cmd/untap.rb
+++ b/Library/Homebrew/cmd/untap.rb
@@ -6,7 +6,7 @@ module Homebrew
raise "Usage is `brew untap <tap-name>`" if ARGV.empty?
ARGV.named.each do |tapname|
- tap = Tap.new(*tap_args(tapname))
+ tap = Tap.fetch(*tap_args(tapname))
raise TapUnavailableError, tap.name unless tap.installed?
puts "Untapping #{tap}... (#{tap.path.abv})"
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb
index 917244a8d..b50348bcf 100644
--- a/Library/Homebrew/cmd/update.rb
+++ b/Library/Homebrew/cmd/update.rb
@@ -63,6 +63,8 @@ module Homebrew
end
end
+ Tap.clear_cache
+
# automatically tap any migrated formulae's new tap
report.select_formula(:D).each do |f|
next unless (dir = HOMEBREW_CELLAR/f).exist?
@@ -372,7 +374,7 @@ class Report
user = $1
repo = $2.sub("homebrew-", "")
oldname = path.basename(".rb").to_s
- next unless newname = Tap.new(user, repo).formula_renames[oldname]
+ next unless newname = Tap.fetch(user, repo).formula_renames[oldname]
else
oldname = path.basename(".rb").to_s
next unless newname = FORMULA_RENAMES[oldname]