diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-12 20:10:59 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-12 22:29:56 -0200 |
commit | b01fd08a8c51b2efea242b93619508707ac0725d (patch) | |
tree | 322b30ed27033d06f14ff2934ea049407e5456ba /actionpack/lib/action_view/helpers | |
parent | 8bc065ee654b3917b9e058c92b649672cec5c2dd (diff) | |
download | rails-b01fd08a8c51b2efea242b93619508707ac0725d.tar.gz rails-b01fd08a8c51b2efea242b93619508707ac0725d.tar.bz2 rails-b01fd08a8c51b2efea242b93619508707ac0725d.zip |
Return faster when no option is given
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/tag_helper.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index 523a7f74c9..37a3fa290e 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -130,21 +130,20 @@ module ActionView end def tag_options(options, escape = true) - unless options.blank? - attrs = [] - options.each_pair do |key, value| - if key.to_s == 'data' && value.is_a?(Hash) - value.each do |k, v| - attrs << data_tag_option(k, v, escape) - end - elsif BOOLEAN_ATTRIBUTES.include?(key) - attrs << boolean_tag_option(key, value) if value - elsif !value.nil? - attrs << tag_option(key, value, escape) + return if options.blank? + attrs = [] + options.each_pair do |key, value| + if key.to_s == 'data' && value.is_a?(Hash) + value.each do |k, v| + attrs << data_tag_option(k, v, escape) end + elsif BOOLEAN_ATTRIBUTES.include?(key) + attrs << boolean_tag_option(key, value) if value + elsif !value.nil? + attrs << tag_option(key, value, escape) end - " #{attrs.sort * ' '}".html_safe unless attrs.empty? end + " #{attrs.sort * ' '}".html_safe unless attrs.empty? end def data_tag_option(k, v, escape) |