1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Instead of marking raw text in templates as safe, and then putting them through String#<< which checks if the String is safe, use safe_concat, which uses the original (internal) String#<< and leaves the safe flag as is. Results in a significant performance improvement.

This commit is contained in:
Yehuda Katz 2009-12-24 21:49:50 -08:00
parent baaaf2acaa
commit f3b072189a
2 changed files with 3 additions and 1 deletions

View file

@ -10,7 +10,8 @@ module ActionView
end end
def add_text(src, text) def add_text(src, text)
src << "@output_buffer << ('" << escape_text(text) << "'.html_safe!);" return if text.empty?
src << "@output_buffer.safe_concat('" << escape_text(text) << "');"
end end
def add_expr_literal(src, code) def add_expr_literal(src, code)

View file

@ -23,6 +23,7 @@ class String
end end
alias original_concat << alias original_concat <<
alias safe_concat <<
def <<(other) def <<(other)
result = original_concat(other) result = original_concat(other)
unless html_safe? && also_html_safe?(other) unless html_safe? && also_html_safe?(other)