From 7d2400ab61c8e3ed95e14d03ba3844e8ba2e36e4 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 27 Apr 2018 03:20:44 +0900 Subject: [PATCH] Don't try to destoy the given string via method argument Or it would raise if the argument was frozen. And even with this change, it would still reduce String allocations together with 9276ea89d2b0be9fdd1ad6590857f8d45a38c267 because `escape` should be `true` in most cases --- actionview/lib/action_view/helpers/tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index 42a9277564603..146bd5ee246c8 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -88,7 +88,7 @@ def tag_option(key, value, escape) if value.is_a?(Array) value = escape ? safe_join(value, " ".freeze) : value.join(" ".freeze) else - value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s + value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s.dup end value.gsub!('"'.freeze, '"'.freeze) %(#{key}="#{value}")