From 33a6bd390affdeb0b403f513be92a5b1547f6e4e Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 20 Dec 2009 17:03:38 -0800 Subject: Fixes Dependency bug in ActiveSupport --- activesupport/lib/active_support/core_ext/date/calculations.rb | 1 + activesupport/lib/active_support/core_ext/date/conversions.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index 3dd61334d0..2b76b93153 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -1,3 +1,4 @@ +require 'date' require 'active_support/duration' require 'active_support/core_ext/time/zones' diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb index f6c870035b..90ab1eb281 100644 --- a/activesupport/lib/active_support/core_ext/date/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date/conversions.rb @@ -1,3 +1,4 @@ +require 'date' require 'active_support/inflector' class Date -- cgit v1.2.3 From b4ecb5555100cc67011637d261e5de30f5b7fcba Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 20 Dec 2009 17:33:31 -0800 Subject: Missing acts_like dependency --- activesupport/lib/active_support/core_ext/time/calculations.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 4f4492f0fd..703b89ffd0 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -1,4 +1,5 @@ require 'active_support/duration' +require 'active_support/core_ext/date/acts_like' require 'active_support/core_ext/date/calculations' class Time -- cgit v1.2.3 From f3b072189a6a77717f99e38403392a68f5818a49 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 24 Dec 2009 21:49:50 -0800 Subject: 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. --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport/lib/active_support/core_ext') 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 a2a88eb7df..9db563f78b 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -23,6 +23,7 @@ class String end alias original_concat << + alias safe_concat << def <<(other) result = original_concat(other) unless html_safe? && also_html_safe?(other) -- cgit v1.2.3 From 3b1642c23cb433dde3d96f0b70dfdc66d15f6713 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 24 Dec 2009 22:44:21 -0800 Subject: Simplify and improve the performance of output_safety --- .../core_ext/string/output_safety.rb | 28 +++++----------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') 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 -- cgit v1.2.3