diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-08 20:21:48 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-08 20:28:09 +0100 |
commit | d1abf29e796a86cbac315da217f3fe7addb88106 (patch) | |
tree | 63456927eb5a45b45581f7b81f82e89c7196e2c7 /railties/guides/code/getting_started/Rakefile | |
parent | 7280787a53436046e992305a235e66e4fb458e0f (diff) | |
download | rails-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 'railties/guides/code/getting_started/Rakefile')
0 files changed, 0 insertions, 0 deletions