diff options
author | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-24 22:44:21 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-24 22:44:21 -0800 |
commit | 3b1642c23cb433dde3d96f0b70dfdc66d15f6713 (patch) | |
tree | 870670be7a48e43dfa0bc5ea27f8e657677d1517 /activesupport/lib/active_support | |
parent | f3b072189a6a77717f99e38403392a68f5818a49 (diff) | |
download | rails-3b1642c23cb433dde3d96f0b70dfdc66d15f6713.tar.gz rails-3b1642c23cb433dde3d96f0b70dfdc66d15f6713.tar.bz2 rails-3b1642c23cb433dde3d96f0b70dfdc66d15f6713.zip |
Simplify and improve the performance of output_safety
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/output_safety.rb | 28 |
1 files changed, 6 insertions, 22 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 9db563f78b..3e6ab0ebd2 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -1,7 +1,6 @@ class String - def html_safe? - defined?(@_rails_html_safe) && @_rails_html_safe - end + attr_accessor :_rails_html_safe + alias html_safe? _rails_html_safe def html_safe! @_rails_html_safe = true @@ -15,31 +14,16 @@ class String alias original_plus + def +(other) result = original_plus(other) - if html_safe? && also_html_safe?(other) - result.html_safe! - else - result - end + result._rails_html_safe = html_safe? && other.html_safe? + result end alias original_concat << alias safe_concat << def <<(other) + @_rails_html_safe = false unless other.html_safe? result = original_concat(other) - unless html_safe? && also_html_safe?(other) - @_rails_html_safe = false - end - result end - remove_method :concat - def concat(other) - self << other - end - - private - def also_html_safe?(other) - other.respond_to?(:html_safe?) && other.html_safe? - end - + alias concat << end
\ No newline at end of file |