From: "Marcin Mielżyński" Date: 2008-04-02T02:20:14+09:00 Subject: Re: Why Ruby do not optimize code at all? ts pisze: > Marcin Mielżyński wrote: >> Well, that's why I'd rather call it temporary breakage since the sources >> say the author's been aware of it from very beginning (chance the TODO: >> comment). Just, opt_case_dispatch impl is not complete _yet_, still >> being faster by default by not using funcall dispatch. > > The TODO has nothing to do with this problem. It has worked one day > on early version of 1.9, then matz has modified the class Symbol > and brutally ruby failed because the optimisation was not removed This case ? ruby -ve "puts :a === 'a'" ruby 1.8.6 (2008-02-02 patchlevel 5000) [i686-linux] false ./ruby -ve "puts :a === 'a'" ruby 1.9.0 (2008-04-01 revision 15368) [i686-linux] true I still claim opt_case_dispatch will be responsible for the fallback like any other opt_* opcode and no optimization will be removed. > > vgs% cat b.rb > #!/usr/bin/ruby > class Symbol > def === other > puts "foo" > end > end > case :s > when :s > puts "s" > end > vgs% > > vgs% /usr/bin/ruby -v b.rb > ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux] > b.rb:3: warning: method redefined; discarding old === > foo > vgs% > > vgs% ./ruby -v b.rb > ruby 1.9.0 (2008-04-01 revision 15881) [i686-linux] > b.rb:3: warning: method redefined; discarding old === > foo > vgs% > That's a bit surprising for me: ruby -v a.rb ruby 1.8.6 (2008-02-02 patchlevel 5000) [i686-linux] a.rb:2: warning: method redefined; discarding old === foo ./ruby -v a.rb ruby 1.9.0 (2008-04-01 revision 15368) [i686-linux] a.rb:2: warning: method redefined; discarding old === s Since opt_case_dispatch doesn't fallback yet. lopex