From d3071db1200e90c0533f75b967c4afb519656d00 Mon Sep 17 00:00:00 2001 From: Xavier Noria <fxn@hashref.com> Date: Sun, 12 Feb 2012 15:49:44 -0800 Subject: boosts inflections The impact of this change has been measured pluralizing the entire /usr/share/dict/words, showing a 6x speedup --- activesupport/lib/active_support/inflector/methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 4b7c36f839..b1ff92151e 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -308,7 +308,7 @@ module ActiveSupport def apply_inflections(word, rules) result = word.to_s.dup - if word.empty? || inflections.uncountables.any? { |inflection| result =~ /\b#{inflection}\Z/i } + if word.empty? || inflections.uncountables.include?(result.downcase[/\b\w+\Z/, 0]) result else rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } -- cgit v1.2.3