bind_local_variable_get: 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 11:27:30 +09:00
Родитель 82ed66a75a
Коммит 2390a8bd2e
1 изменённых файлов: 6 добавлений и 6 удалений

12
proc.c
Просмотреть файл

@ -541,14 +541,14 @@ bind_local_variable_get(VALUE bindval, VALUE sym)
GetBindingPtr(bindval, bind);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
if ((ptr = get_local_variable_ptr(&env, lid)) == NULL) {
sym = ID2SYM(lid);
undefined:
rb_name_err_raise("local variable `%1$s' is not defined for %2$s",
bindval, sym);
if ((ptr = get_local_variable_ptr(&env, lid)) != NULL) {
return *ptr;
}
return *ptr;
sym = ID2SYM(lid);
undefined:
rb_name_err_raise("local variable `%1$s' is not defined for %2$s",
bindval, sym);
}
/*