proc.c: recursion loop
* proc.c (rb_block_min_max_arity, rb_method_entry_min_max_arity): turn loop by recursion into goto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4bf532ad97
commit
8a7419814c
8
proc.c
8
proc.c
@ -928,11 +928,13 @@ rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
|
|||||||
static int
|
static int
|
||||||
rb_block_min_max_arity(const struct rb_block *block, int *max)
|
rb_block_min_max_arity(const struct rb_block *block, int *max)
|
||||||
{
|
{
|
||||||
|
again:
|
||||||
switch (vm_block_type(block)) {
|
switch (vm_block_type(block)) {
|
||||||
case block_type_iseq:
|
case block_type_iseq:
|
||||||
return rb_iseq_min_max_arity(rb_iseq_check(block->as.captured.code.iseq), max);
|
return rb_iseq_min_max_arity(rb_iseq_check(block->as.captured.code.iseq), max);
|
||||||
case block_type_proc:
|
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:
|
case block_type_ifunc:
|
||||||
{
|
{
|
||||||
const struct vm_ifunc *ifunc = block->as.captured.code.ifunc;
|
const struct vm_ifunc *ifunc = block->as.captured.code.ifunc;
|
||||||
@ -2223,6 +2225,7 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
|
|||||||
{
|
{
|
||||||
const rb_method_definition_t *def = me->def;
|
const rb_method_definition_t *def = me->def;
|
||||||
|
|
||||||
|
again:
|
||||||
if (!def) return *max = 0;
|
if (!def) return *max = 0;
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VM_METHOD_TYPE_CFUNC:
|
case VM_METHOD_TYPE_CFUNC:
|
||||||
@ -2239,7 +2242,8 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
|
|||||||
case VM_METHOD_TYPE_IVAR:
|
case VM_METHOD_TYPE_IVAR:
|
||||||
return *max = 0;
|
return *max = 0;
|
||||||
case VM_METHOD_TYPE_ALIAS:
|
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:
|
case VM_METHOD_TYPE_BMETHOD:
|
||||||
return rb_proc_min_max_arity(def->body.proc, max);
|
return rb_proc_min_max_arity(def->body.proc, max);
|
||||||
case VM_METHOD_TYPE_ISEQ:
|
case VM_METHOD_TYPE_ISEQ:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user