Skip to content
  • José Valim's avatar
    d1abf29e
    Remove NilClass whiners feature. · d1abf29e
    José Valim authored
    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 } }
    d1abf29e
    Remove NilClass whiners feature.
    José Valim authored
    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 } }
Loading