ruby-changes:46391
From: nobu <ko1@a...>
Date: Sat, 29 Apr 2017 19:27:52 +0900 (JST)
Subject: [ruby-changes:46391] nobu:r58505 (trunk): proc.c: recursion loop
nobu 2017-04-29 19:27:46 +0900 (Sat, 29 Apr 2017) New Revision: 58505 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58505 Log: proc.c: recursion loop * proc.c (rb_block_min_max_arity, rb_method_entry_min_max_arity): turn loop by recursion into goto. Modified files: trunk/proc.c Index: proc.c =================================================================== --- proc.c (revision 58504) +++ proc.c (revision 58505) @@ -928,11 +928,13 @@ rb_iseq_min_max_arity(const rb_iseq_t *i https://github.com/ruby/ruby/blob/trunk/proc.c#L928 static int rb_block_min_max_arity(const struct rb_block *block, int *max) { + again: switch (vm_block_type(block)) { case block_type_iseq: return rb_iseq_min_max_arity(rb_iseq_check(block->as.captured.code.iseq), max); case block_type_proc: - return rb_block_min_max_arity(vm_proc_block(block->as.proc), max); + block = vm_proc_block(block->as.proc); + goto again; case block_type_ifunc: { const struct vm_ifunc *ifunc = block->as.captured.code.ifunc; @@ -2223,6 +2225,7 @@ rb_method_entry_min_max_arity(const rb_m https://github.com/ruby/ruby/blob/trunk/proc.c#L2225 { const rb_method_definition_t *def = me->def; + again: if (!def) return *max = 0; switch (def->type) { case VM_METHOD_TYPE_CFUNC: @@ -2239,7 +2242,8 @@ rb_method_entry_min_max_arity(const rb_m https://github.com/ruby/ruby/blob/trunk/proc.c#L2242 case VM_METHOD_TYPE_IVAR: return *max = 0; case VM_METHOD_TYPE_ALIAS: - return rb_method_entry_min_max_arity(def->body.alias.original_me, max); + def = def->body.alias.original_me->def; + goto again; case VM_METHOD_TYPE_BMETHOD: return rb_proc_min_max_arity(def->body.proc, max); case VM_METHOD_TYPE_ISEQ: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/