diff options
author | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-24 21:49:50 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-24 21:50:18 -0800 |
commit | f3b072189a6a77717f99e38403392a68f5818a49 (patch) | |
tree | a8d3e8d3ce07d02e4f645dec2e6fb13ee5396404 /actionpack/lib/action_view | |
parent | baaaf2acaa58748bf9dc49859d1bca3ed273dc65 (diff) | |
download | rails-f3b072189a6a77717f99e38403392a68f5818a49.tar.gz rails-f3b072189a6a77717f99e38403392a68f5818a49.tar.bz2 rails-f3b072189a6a77717f99e38403392a68f5818a49.zip |
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.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index f8e6376589..93a4315108 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -10,7 +10,8 @@ module ActionView end 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 def add_expr_literal(src, code) |