mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Perf optimization for url_for
called w/ Hash
Benchmarking the existing code: ```ruby { :only_path => options[:host].nil? }.merge!(options.symbolize_keys)) ``` Against optimized code, that does not require a new hash or a merge: ```ruby options = options.symbolize_keys options[:only_path] = options[:host].nil? unless options.key?(:only_path) options ``` We see a statistically significant performance gain: ![](https://www.dropbox.com/s/onocpc0zfw4kjxl/Screenshot%202014-08-14%2012.45.30.png?dl=1) Updated to not mutate incoming parameters
This commit is contained in:
parent
71e8f199d7
commit
4d47220d7c
1 changed files with 3 additions and 1 deletions
|
@ -82,7 +82,9 @@ module ActionView
|
|||
when nil
|
||||
super({:only_path => true})
|
||||
when Hash
|
||||
super({ :only_path => options[:host].nil? }.merge!(options.symbolize_keys))
|
||||
options = options.symbolize_keys
|
||||
options[:only_path] = options[:host].nil? unless options.key?(:only_path)
|
||||
super(options)
|
||||
when :back
|
||||
_back_url
|
||||
when Symbol
|
||||
|
|
Loading…
Reference in a new issue