aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-02-12 15:49:44 -0800
committerXavier Noria <fxn@hashref.com>2012-02-12 15:58:10 -0800
commitd3071db1200e90c0533f75b967c4afb519656d00 (patch)
treedc7919de4c03b3e694d7cd06b3be34f02df4a0cb /activesupport/lib/active_support/inflector
parent815e4453310858f9cfbccf4b41f943c9448aea07 (diff)
downloadrails-d3071db1200e90c0533f75b967c4afb519656d00.tar.gz
rails-d3071db1200e90c0533f75b967c4afb519656d00.tar.bz2
rails-d3071db1200e90c0533f75b967c4afb519656d00.zip
boosts inflections
The impact of this change has been measured pluralizing the entire /usr/share/dict/words, showing a 6x speedup
Diffstat (limited to 'activesupport/lib/active_support/inflector')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb2
1 files changed, 1 insertions, 1 deletions
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) }