aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2016-03-23 14:55:42 +0800
committerXu Cheng2016-03-23 15:01:28 +0800
commit6e27e2db741da39e3c8f0d9668a9c356a81130d2 (patch)
treeb877ccc8270ee42f979c05aa08e3e56fd6ac29fd /Library
parent760c596a8e75c6126e95cb9897eb9b66faffbb0c (diff)
downloadbrew-6e27e2db741da39e3c8f0d9668a9c356a81130d2.tar.bz2
tap: cache dir path to avoid duplicated Pathname operations
As discovered in Homebrew/homebrew#50256, this becomes a performance bottleneck as we are repeating construct same Pathname object. At the same, this commit makes the behaviors between Tap and CoreTap more consistence.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/tap.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 5883c779c..17e84d1b0 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -71,6 +71,7 @@ class Tap
@remote = nil
@formula_dir = nil
@formula_files = nil
+ @alias_dir = nil
@alias_files = nil
@aliases = nil
@alias_table = nil
@@ -298,7 +299,7 @@ class Tap
# path to the directory of all alias files for this {Tap}.
# @private
def alias_dir
- path/"Aliases"
+ @alias_dir ||= path/"Aliases"
end
# an array of all alias files of this {Tap}.
@@ -500,12 +501,12 @@ class CoreTap < Tap
# @private
def formula_dir
- HOMEBREW_LIBRARY/"Formula"
+ @formula_dir ||= HOMEBREW_LIBRARY/"Formula"
end
# @private
def alias_dir
- HOMEBREW_LIBRARY/"Aliases"
+ @alias_dir ||= HOMEBREW_LIBRARY/"Aliases"
end
# @private