diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-04 09:05:45 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-04 09:05:45 -0700 |
commit | e865d125431424562b5e252ed151f6bae8dd5e8f (patch) | |
tree | 93c181f5831e772f6ab044516fb36be43dbd3aa3 /actionpack/lib/action_view | |
parent | abb09054043c556ae38d2c9d1e9037eceb6dc426 (diff) | |
parent | 9b08afd2f4d501fb1710ba0ed4e19313093605c8 (diff) | |
download | rails-e865d125431424562b5e252ed151f6bae8dd5e8f.tar.gz rails-e865d125431424562b5e252ed151f6bae8dd5e8f.tar.bz2 rails-e865d125431424562b5e252ed151f6bae8dd5e8f.zip |
Merge pull request #2852 from milandobrota/remove_unneeded_explicit_nil_checks
if ... nil? is more expensive than unless
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/asset_paths.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/asset_paths.rb b/actionpack/lib/action_view/asset_paths.rb index aae8377f8a..73f4f8ee5f 100644 --- a/actionpack/lib/action_view/asset_paths.rb +++ b/actionpack/lib/action_view/asset_paths.rb @@ -69,7 +69,7 @@ module ActionView host = "#{compute_protocol(protocol)}#{host}" end end - host.nil? ? source : "#{host}#{source}" + host ? "#{host}#{source}" : source end def compute_protocol(protocol) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 1ceb53fe9c..13b9dc8553 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -656,7 +656,7 @@ module ActionView if token == false || !protect_against_forgery? '' else - token = form_authenticity_token if token.nil? + token ||= form_authenticity_token tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => token) end end diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 4dbb0135f6..0cdc103df3 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -596,9 +596,7 @@ module ActionView private def convert_options_to_data_attributes(options, html_options) - if html_options.nil? - link_to_remote_options?(options) ? {'data-remote' => 'true'} : {} - else + if html_options html_options = html_options.stringify_keys html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options) @@ -611,6 +609,8 @@ module ActionView add_method_to_attributes!(html_options, method) if method html_options + else + link_to_remote_options?(options) ? {'data-remote' => 'true'} : {} end end |