rails/rails — comment on commit c41f08cefe6fa3747ee79001d9c88dc988e8064d
File: actionpack/lib/action_dispatch/routing/url_for.rb line 148
By sobrinho:

It's more faster using this way:

``` ruby
_routes.url_for((options.try(:symbolize_keys) || {}).reverse_merge!(url_options))
```

My benchmark:

``` ruby
require 'benchmark'
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/object/try'

options = nil

puts Benchmark.realtime { 1_000_000.times { (options || {}).symbolize_keys } }
puts Benchmark.realtime { 1_000_000.times { (options.try(:symbolize_keys) || {}) } }
```

```
1.030134
0.417733
```

Could you check that @josevalim and @tenderlove?

Obviously this will be better if options is normally nil but I guess this is the case in many situations.