Browse files

Speedup AS::Inflector.camelize

Benchmark:
          user     system      total        real
old   5.960000   0.020000   5.980000 (  5.981754)
new   5.740000   0.030000   5.770000 (  5.757201)
  • Loading branch information...
1 parent cd0d590 commit ff8cbdd05b22fc7992c34eb12c7aa3da495555b8 @amatsuda amatsuda committed Jul 10, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 activesupport/lib/active_support/inflector/methods.rb
View
4 activesupport/lib/active_support/inflector/methods.rb
@@ -72,7 +72,9 @@ def camelize(term, uppercase_first_letter = true)
else
string = string.sub(/^(?:#{inflections.acronym_regex}(?=\b|[A-Z_])|\w)/) { $&.downcase }
end
- string.gsub(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" }.gsub('/', '::')
+ string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" }
+ string.gsub!('/', '::')
+ string
end
# Makes an underscored, lowercase form from the expression in the string.

0 comments on commit ff8cbdd

Please sign in to comment.