aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-08 20:21:48 +0100
committerJosé Valim <jose.valim@gmail.com>2011-12-08 20:28:09 +0100
commitd1abf29e796a86cbac315da217f3fe7addb88106 (patch)
tree63456927eb5a45b45581f7b81f82e89c7196e2c7 /activerecord
parent7280787a53436046e992305a235e66e4fb458e0f (diff)
downloadrails-d1abf29e796a86cbac315da217f3fe7addb88106.tar.gz
rails-d1abf29e796a86cbac315da217f3fe7addb88106.tar.bz2
rails-d1abf29e796a86cbac315da217f3fe7addb88106.zip
Remove NilClass whiners feature.
Removing this feature causes boost in performance when using Ruby 1.9. Ruby 1.9 started to do implicit conversions using `to_ary` and `to_str` in some STDLIB methods (like Array#join). To do such implicit conversions, Ruby 1.9 always dispatches the method and rescues the NoMethodError exception in case one is raised. Therefore, since the whiners feature defined NilClass#method_missing, such implicit conversions for nil became much, much slower. In fact, just defining NilClass#method_missing (even without the whiners feature) already causes a massive slow down. Here is a snippet that shows such slow down: require "benchmark" Benchmark.realtime { 1_000.times { [nil,nil,nil].join } } class NilClass def method_missing(*args) raise NoMethodError end end Benchmark.realtime { 1_000.times { [nil,nil,nil].join } }
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb2
1 files changed, 0 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 7ba585b8e0..58d23d2f78 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2222,8 +2222,6 @@ MSG
include AutosaveAssociation, NestedAttributes
include Aggregations, Transactions, Reflection, Serialization, Store
- NilClass.add_whiner(self) if NilClass.respond_to?(:add_whiner)
-
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
# (Alias for the protected read_attribute method).