From 0844c87f666e264c43e73253d686ebcbc0154479 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 21 Feb 2014 00:43:58 -0500 Subject: Cache generated class names --- Library/Homebrew/formulary.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Library') 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. -- cgit v1.2.3