proc_binding: do not goto into a branch

I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
This commit is contained in:
卜部昌平 2020-06-16 12:24:30 +09:00
parent 3db159193e
commit 2bfac015d3
Notes: git 2020-06-29 11:06:54 +09:00

11
proc.c
View File

@ -3229,8 +3229,6 @@ proc_binding(VALUE self)
GetProcPtr(block->as.proc, proc); GetProcPtr(block->as.proc, proc);
block = &proc->block; block = &proc->block;
goto again; goto again;
case block_type_symbol:
goto error;
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;
@ -3247,12 +3245,11 @@ proc_binding(VALUE self)
RB_OBJ_WRITE(env, &env->iseq, empty); RB_OBJ_WRITE(env, &env->iseq, empty);
break; break;
} }
else {
error:
rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
return Qnil;
}
} }
/* FALLTHROUGH */
case block_type_symbol:
rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
UNREACHABLE_RETURN(Qnil);
} }
bindval = rb_binding_alloc(rb_cBinding); bindval = rb_binding_alloc(rb_cBinding);