diff options
| author | Jack Nagel | 2014-02-21 00:43:58 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-02-21 00:46:03 -0500 |
| commit | da87bdc2e55f18fdc1b184f8e123711429167735 (patch) | |
| tree | 77ef8b6bd42734b6b19064a1e5e97cb308a3ca48 /Library | |
| parent | 41a9ba8259be9e7fd9013df5498e9ddc7b0a1928 (diff) | |
| download | brew-da87bdc2e55f18fdc1b184f8e123711429167735.tar.bz2 | |
Cache generated class names
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formulary.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index e99dc0815..350854bba 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -21,10 +21,12 @@ class Formulary end def self.class_s name - name = name.capitalize - name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } - name.gsub!('+', 'x') - name + (@class_s ||= {}).fetch(name) do + class_name = name.capitalize + class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } + class_name.gsub!('+', 'x') + @class_s[name] = class_name + end end # A FormulaLoader returns instances of formulae. |
