aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2013-12-10 09:44:05 -0800
committerJosé Valim <jose.valim@plataformatec.com.br>2013-12-10 09:44:05 -0800
commitdbe6a8b03b78c0729a39cc849ca8b79752c65235 (patch)
treedc4d481d43e5132430063c76ac1d38da2848ce03 /activesupport
parentbd360ad3c1d59273bf96ea01b17cf04285816dc2 (diff)
parent88cff33a63699d08220411b0090f2f0e40c15cf3 (diff)
downloadrails-dbe6a8b03b78c0729a39cc849ca8b79752c65235.tar.gz
rails-dbe6a8b03b78c0729a39cc849ca8b79752c65235.tar.bz2
rails-dbe6a8b03b78c0729a39cc849ca8b79752c65235.zip
Merge pull request #13257 from eshira/optimize-gsub
Replace with gsub! in ActiveSupport::Inflector
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index 0f7ae98a8a..cdee4c2ca5 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -117,7 +117,8 @@ module ActiveSupport
result.gsub!(/([a-z\d]*)/i) { |match|
"#{inflections.acronyms[match] || match.downcase}"
}
- options.fetch(:capitalize, true) ? result.gsub(/^\w/) { $&.upcase } : result
+ result.gsub!(/^\w/) { $&.upcase } if options.fetch(:capitalize, true)
+ result
end
# Capitalizes all the words and replaces some characters in the string to