From 2390a8bd2ef197faf94b5251ee9a0ea582ff6fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 16 Jun 2020 11:27:30 +0900 Subject: [PATCH] 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. --- proc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/proc.c b/proc.c index 36f537603b..371aa83dc0 100644 --- a/proc.c +++ b/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); } /*