diff options
author | schneems <richard.schneeman@gmail.com> | 2015-07-24 23:35:18 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2015-07-29 20:41:58 -0500 |
commit | 2a4d4301d405dbc4a6bce85b4632a78099c8d1c6 (patch) | |
tree | 3525a194930f1f3072602705806c0cc29b52b5f0 /actionview/lib/action_view/helpers/debug_helper.rb | |
parent | 1a14074fb525cde4a439a1fb7515fe417c37ff96 (diff) | |
download | rails-2a4d4301d405dbc4a6bce85b4632a78099c8d1c6.tar.gz rails-2a4d4301d405dbc4a6bce85b4632a78099c8d1c6.tar.bz2 rails-2a4d4301d405dbc4a6bce85b4632a78099c8d1c6.zip |
Decrease string allocation in content_tag_string
When an unknonwn key is passed to the hash in `PRE_CONTENT_STRINGS` it returns nil, when you call "#{nil}" it allocates a new empty string. We can get around this allocation by using a default value `Hash.new { "".freeze }`. We can avoid the `to_sym` call by pre-populating the hash with a symbol key in addition to a string key.
We can freeze some strings when using Array#* to reduce allocations.
Array#join can take frozen strings.
This change buys us 86,600 bytes of memory and 1,857 fewer objects per request.
Diffstat (limited to 'actionview/lib/action_view/helpers/debug_helper.rb')
0 files changed, 0 insertions, 0 deletions