Skip to content

Commit

Permalink
boosts inflections
Browse files Browse the repository at this point in the history
The impact of this change has been measured pluralizing
the entire /usr/share/dict/words, showing a 6x speedup
  • Loading branch information
fxn committed Feb 12, 2012
1 parent 815e445 commit d3071db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/inflector/methods.rb
Expand Up @@ -308,7 +308,7 @@ def const_regexp(camel_cased_word) #:nodoc:
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])

This comment has been minimized.

Copy link
@fxn

fxn Feb 13, 2012

Author Member

Redundant 0 removed in dc03a2f.

result
else
rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
Expand Down

0 comments on commit d3071db

Please sign in to comment.