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:
parent
82ed66a75a
commit
2390a8bd2e
Notes:
git
2020-06-29 11:06:55 +09:00
8
proc.c
8
proc.c
@ -541,16 +541,16 @@ 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) {
|
||||
if ((ptr = get_local_variable_ptr(&env, lid)) != NULL) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
sym = ID2SYM(lid);
|
||||
undefined:
|
||||
rb_name_err_raise("local variable `%1$s' is not defined for %2$s",
|
||||
bindval, sym);
|
||||
}
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* binding.local_variable_set(symbol, obj) -> obj
|
||||
|
Loading…
x
Reference in New Issue
Block a user