From: ts Date: 2008-04-23T17:37:46+09:00 Subject: Re: Performance on method dispatch for methods defined via define_method Robert Dober wrote: > However, if and only if, the block in the define_method does not use > the closure we could really inline the block as the code of a method > defined with def. What do you want to say with "inline" ? vgs% ./ruby -e 'puts VM::InstructionSequence.compile("proc {|x| x = 12 }.call(1)").disasm' == disasm: @>================================= == catch table | catch type: break st: 0000 ed: 0007 sp: 0000 cont: 0007 |------------------------------------------------------------------------ 0000 putnil ( 1) 0001 send :proc, 0, block in , 8, 0007 putobject 1 0009 send :call, 1, nil, 0, 0015 leave == disasm: @>======================== == catch table | catch type: redo st: 0000 ed: 0006 sp: 0000 cont: 0000 | catch type: next st: 0000 ed: 0006 sp: 0000 cont: 0006 |------------------------------------------------------------------------ local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s3) [ 1] x 0000 putobject 12 ( 1) 0002 dup 0003 setdynamic x, 0 0006 leave vgs% vgs% ./ruby -e 'puts VM::InstructionSequence.compile("def a(x) x = 12; end; a(1)").disasm' == disasm: @>================================= 0000 putnil ( 1) 0001 definemethod :a, a, 0 0005 putnil 0006 putobject 1 0008 send :a, 1, nil, 8, 0014 leave == disasm: >========================================== local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s1) [ 2] x 0000 putobject 12 ( 1) 0002 dup 0003 setlocal x 0005 leave vgs% Guy Decoux