Skip to content

Commit dbe6a8b

Browse files
author
José Valim
committed
Merge pull request rails#13257 from eshira/optimize-gsub
Replace with gsub! in ActiveSupport::Inflector
2 parents bd360ad + 88cff33 commit dbe6a8b

File tree

1 file changed

+2
-1
lines changed
  • activesupport/lib/active_support/inflector

1 file changed

+2
-1
lines changed

activesupport/lib/active_support/inflector/methods.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def humanize(lower_case_and_underscored_word, options = {})
117117
result.gsub!(/([a-z\d]*)/i) { |match|
118118
"#{inflections.acronyms[match] || match.downcase}"
119119
}
120-
options.fetch(:capitalize, true) ? result.gsub(/^\w/) { $&.upcase } : result
120+
result.gsub!(/^\w/) { $&.upcase } if options.fetch(:capitalize, true)
121+
result
121122
end
122123

123124
# Capitalizes all the words and replaces some characters in the string to

0 commit comments

Comments
 (0)