diff options
| author | Jack Nagel | 2013-04-14 21:32:30 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-14 21:41:30 -0500 |
| commit | 0bb33f8b10886277845d1193f7139307cdceed57 (patch) | |
| tree | 348aa48ad9b5ceda56f528a00da4c399c569ab0f /Library/Homebrew/formula_pin.rb | |
| parent | bed85d1a5dd16b3b199ebbad0013436a31aa0a59 (diff) | |
| download | homebrew-0bb33f8b10886277845d1193f7139307cdceed57.tar.bz2 | |
Avoid slow operations in FormulaPin#initialize
A FormulaPin object is created every time Formula is instantiated, so
don't do filesystem operations or Pathname concatenation eagerly.
Diffstat (limited to 'Library/Homebrew/formula_pin.rb')
| -rw-r--r-- | Library/Homebrew/formula_pin.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Library/Homebrew/formula_pin.rb b/Library/Homebrew/formula_pin.rb index c809a02b8..c6740f104 100644 --- a/Library/Homebrew/formula_pin.rb +++ b/Library/Homebrew/formula_pin.rb @@ -6,13 +6,16 @@ class FormulaPin def initialize(formula) @formula = formula @name = formula.name - HOMEBREW_PINNED.mkdir unless HOMEBREW_PINNED.exist? - @path = HOMEBREW_PINNED+@name + end + + def path + HOMEBREW_PINNED+@name end def pin_at(version) + HOMEBREW_PINNED.mkpath unless HOMEBREW_PINNED.exist? version_path = @formula.installed_prefix.parent.join(version) - FileUtils.ln_s version_path, @path unless pinned? or not version_path.exist? + FileUtils.ln_s version_path, path unless pinned? or not version_path.exist? end def pin @@ -22,11 +25,11 @@ class FormulaPin end def unpin - FileUtils.rm @path if pinned? + FileUtils.rm path if pinned? end def pinned? - @path.symlink? + path.symlink? end def pinable? |
