ruby-changes:42835
From: nobu <ko1@a...>
Date: Wed, 4 May 2016 18:13:29 +0900 (JST)
Subject: [ruby-changes:42835] nobu:r54909 (trunk): proc.c: passed_block
nobu 2016-05-04 19:10:06 +0900 (Wed, 04 May 2016) New Revision: 54909 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54909 Log: proc.c: passed_block * proc.c (passed_block): extract conversion from passed proc value to rb_block_t pointer. Modified files: trunk/proc.c Index: proc.c =================================================================== --- proc.c (revision 54908) +++ proc.c (revision 54909) @@ -805,6 +805,17 @@ check_argc(long argc) https://github.com/ruby/ruby/blob/trunk/proc.c#L805 #define check_argc(argc) (argc) #endif +static rb_block_t * +passed_block(VALUE pass_procval) +{ + if (!NIL_P(pass_procval)) { + rb_proc_t *pass_proc; + GetProcPtr(pass_procval, pass_proc); + return &pass_proc->block; + } + return 0; +} + VALUE rb_proc_call(VALUE self, VALUE args) { @@ -825,12 +836,7 @@ rb_proc_call_with_block(VALUE self, int https://github.com/ruby/ruby/blob/trunk/proc.c#L836 rb_block_t *block = 0; GetProcPtr(self, proc); - if (!NIL_P(pass_procval)) { - rb_proc_t *pass_proc; - GetProcPtr(pass_procval, pass_proc); - block = &pass_proc->block; - } - + block = passed_block(pass_procval); vret = rb_vm_invoke_proc(GET_THREAD(), proc, argc, argv, block); RB_GC_GUARD(self); RB_GC_GUARD(pass_procval); @@ -1977,15 +1983,8 @@ rb_method_call_with_block(int argc, cons https://github.com/ruby/ruby/blob/trunk/proc.c#L1983 } if ((state = EXEC_TAG()) == 0) { rb_thread_t *th = GET_THREAD(); - rb_block_t *block = 0; - - if (!NIL_P(pass_procval)) { - rb_proc_t *pass_proc; - GetProcPtr(pass_procval, pass_proc); - block = &pass_proc->block; - } - th->passed_block = block; + th->passed_block = passed_block(pass_procval); VAR_INITIALIZED(data); result = rb_vm_call(th, data->recv, data->me->called_id, argc, argv, method_callable_method_entry(data)); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/