From 6e27e2db741da39e3c8f0d9668a9c356a81130d2 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 23 Mar 2016 14:55:42 +0800 Subject: 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. --- Library/Homebrew/tap.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Library') 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 -- cgit v1.2.3