aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-06-02 15:46:02 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-02 15:46:14 -0700
commit29a1b77c6b20984c620230afb7590fbfaf4823dd (patch)
tree1912222a519d5cdd84fb7bc72470f85949ced736 /activesupport/lib
parentc07d09559ec171e1904b55c7ad7e8c7d586ca51b (diff)
downloadrails-29a1b77c6b20984c620230afb7590fbfaf4823dd.tar.gz
rails-29a1b77c6b20984c620230afb7590fbfaf4823dd.tar.bz2
rails-29a1b77c6b20984c620230afb7590fbfaf4823dd.zip
reduce AS::SafeBuffer allocations
html_escape_interpolated_argument is only used in mutation methods: https://github.com/rails/rails/blob/c07d09559ec171e1904b55c7ad7e8c7d586ca51b/activesupport/lib/active_support/core_ext/string/output_safety.rb#L174 https://github.com/rails/rails/blob/c07d09559ec171e1904b55c7ad7e8c7d586ca51b/activesupport/lib/active_support/core_ext/string/output_safety.rb#L179 The return value doesn't need to be converted to an AS::SafeBuffer since we know that the current object is an AS::SafeBuffer and will be mutated, and the return value from html_escape_interpolated_argument will be thrown away
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index d922eedbcd..4b88772824 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -233,7 +233,8 @@ module ActiveSupport #:nodoc:
private
def html_escape_interpolated_argument(arg)
- (!html_safe? || arg.html_safe?) ? arg : ERB::Util.h(arg)
+ (!html_safe? || arg.html_safe?) ? arg :
+ arg.to_s.gsub(ERB::Util::HTML_ESCAPE_REGEXP, ERB::Util::HTML_ESCAPE)
end
end
end