mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Decrease string allocations in url_options
The request.script_name is dup-d which allocates an extra string. It is most commonly an empty string "". We can save a ton of string allocations by checking first if the string is empty, if so we can use a frozen empty string instead of duplicating an empty string. This change buys us 35,714 bytes of memory and 893 fewer objects per request.
This commit is contained in:
parent
1bf50badd9
commit
83ee043c68
1 changed files with 5 additions and 1 deletions
|
@ -41,7 +41,11 @@ module ActionController
|
|||
if original_script_name
|
||||
options[:original_script_name] = original_script_name
|
||||
else
|
||||
options[:script_name] = same_origin ? request.script_name.dup : script_name
|
||||
if same_origin
|
||||
options[:script_name] = request.script_name.empty? ? "".freeze : request.script_name.dup
|
||||
else
|
||||
options[:script_name] = script_name
|
||||
end
|
||||
end
|
||||
options.freeze
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue