summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-29 10:27:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-29 10:27:46 +0000
commit8a7419814cf8bd53f8ac6602c5e371545ecfeee4 (patch)
tree4c18ace4851df58ebb4066336173080aa24664ac /proc.c
parent4bf532ad976b3dea13f3ea5710bea54c4c07ca9f (diff)
downloadruby-8a7419814cf8bd53f8ac6602c5e371545ecfeee4.tar.gz
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
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/proc.c b/proc.c
index 58d33b199a..d1a8441c42 100644
--- a/proc.c
+++ b/proc.c
@@ -928,11 +928,13 @@ rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
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_method_entry_t *me, int *max)
{
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_method_entry_t *me, int *max)
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: