Little refactoring for performance

Hi all.

What do you think about this changes https://github.com/rails/rails/compare/master…lvl0nax:am_refactoring?expand=1

Benchmark points

  1. gsub => chomp

str = ‘some_test’

Benchmark.ips do |x|

x.report(“chomp”) { str.chomp(‘_test’) }

x.report(“gsub”) { str.gsub(/_test$/, ‘’) }

x.compare!

end

Calculating -------------------------------------

chomp 135.882k i/100ms

gsub 39.913k i/100ms

Please do submit PRs for each case.

Take care not to mutate the method arg in #2.