aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2014-02-21 00:43:58 -0500
committerJack Nagel2014-02-21 00:46:03 -0500
commit0844c87f666e264c43e73253d686ebcbc0154479 (patch)
treeedf042bbc7ff816e3509660d92c33460310c2e82 /Library/Homebrew
parent3e5ae57a609ddd14a3458424d3bf9cccffe4790b (diff)
downloadhomebrew-0844c87f666e264c43e73253d686ebcbc0154479.tar.bz2
Cache generated class names
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formulary.rb10
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.