diff options
author | Amadeus Folego <amadeusfolego@gmail.com> | 2016-08-22 20:36:45 -0300 |
---|---|---|
committer | Amadeus Folego <amadeusfolego@gmail.com> | 2016-08-22 21:34:39 -0300 |
commit | 735556d6ccbce382724b7c5dc63109c9b324d1ca (patch) | |
tree | 2ba3c09aad571c0d2c66fbe3155099f0900f8eef /actionview | |
parent | debd774d632ae7e1e6c0a7d0306979159df39b63 (diff) | |
download | rails-735556d6ccbce382724b7c5dc63109c9b324d1ca.tar.gz rails-735556d6ccbce382724b7c5dc63109c9b324d1ca.tar.bz2 rails-735556d6ccbce382724b7c5dc63109c9b324d1ca.zip |
Improve TagHelper#tag_option performance
Freeze string literals and use String instead of
Regex inside gsub call. This should improve performance from 20% up to
50% on most cases.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/helpers/tag_helper.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index 4950f272a4..24c6d03cd1 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -86,11 +86,11 @@ module ActionView def tag_option(key, value, escape) if value.is_a?(Array) - value = escape ? safe_join(value, " ") : value.join(" ") + value = escape ? safe_join(value, " ".freeze) : value.join(" ".freeze) else value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s end - %(#{key}="#{value.gsub(/"/, '"'.freeze)}") + %(#{key}="#{value.gsub('"'.freeze, '"'.freeze)}") end private |