From 6d75599a1aade9f8081d0691a9da1e62a5428e95 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 20 Jan 2025 17:35:12 +0900 Subject: refactor: make get_local_variable_ptr accept "rb_env_t *" ... instead of "rb_env_t **" because no one uses the updated env. --- proc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index 06bfaf9b81..e7e011a415 100644 --- a/proc.c +++ b/proc.c @@ -404,9 +404,8 @@ bind_eval(int argc, VALUE *argv, VALUE bindval) } static const VALUE * -get_local_variable_ptr(const rb_env_t **envp, ID lid) +get_local_variable_ptr(const rb_env_t *env, ID lid) { - const rb_env_t *env = *envp; do { if (!VM_ENV_FLAGS(env->ep, VM_FRAME_FLAG_CFRAME)) { if (VM_ENV_FLAGS(env->ep, VM_ENV_FLAG_ISOLATED)) { @@ -430,7 +429,6 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid) } } - *envp = env; unsigned int last_lvar = env->env_size+VM_ENV_INDEX_LAST_LVAR - 1 /* errinfo */; return &env->env[last_lvar - (local_table_size - i)]; @@ -438,12 +436,10 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid) } } else { - *envp = NULL; return NULL; } } while ((env = rb_vm_env_prev_env(env)) != NULL); - *envp = NULL; return NULL; } @@ -533,7 +529,7 @@ 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; } @@ -581,7 +577,7 @@ bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val) 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) { /* not found. create new env */ ptr = rb_binding_add_dynavars(bindval, bind, 1, &lid); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); @@ -624,7 +620,7 @@ bind_local_variable_defined_p(VALUE bindval, VALUE sym) GetBindingPtr(bindval, bind); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); - return RBOOL(get_local_variable_ptr(&env, lid)); + return RBOOL(get_local_variable_ptr(env, lid)); } /* -- cgit v1.2.3