rails/rails — pull request #12879 by tenderlove (2013-11-14 00:33:38+00:00)
Title: 19% reduction is string object allocations per request

Benchmark is here:

https://github.com/tenderlove/ko1-test-app/blob/d4acd6aba86e3be3a16368296277bc973db8d1a7/perf.rake#L96-L109

I ran it like this:

`KO1TEST_PATH=/users/sign_in RAILS_ENV=production rake -f perf.rake allocated_objects`

It runs against a basic devise login page.

I started with `{:T_STRING=>1688.029}` per request, and after this patch is applied it's `{:T_STRING=>1380.029}` per request.

## Merits

* Eliminates *many* string object allocations per request
* Savings grow as your ERb templates grow (the patch freezes string literals in ERb templates)

## Demerits

* `freeze` eliminates allocations on Ruby 2.1, but is extra overhead on Ruby <= 2.0