From: Dmitry Volyntsev Date: Wed, 5 Apr 2023 05:19:48 +0000 (-0700) Subject: VM: removed vm->variables_hash. X-Git-Tag: 0.7.12~2 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=ded21434e1aca13ca50d193d7a4944a98707a3d3;p=njs.git VM: removed vm->variables_hash. --- diff --git a/src/njs_builtin.c b/src/njs_builtin.c index bcffed9a..50a53532 100644 --- a/src/njs_builtin.c +++ b/src/njs_builtin.c @@ -588,7 +588,7 @@ njs_vm_expression_completions(njs_vm_t *vm, njs_str_t *expression) var_node.key = (uintptr_t) lhq.value; - node = njs_rbtree_find(vm->variables_hash, &var_node.node); + node = njs_rbtree_find(&vm->global_scope->variables, &var_node.node); if (njs_slow_path(node == NULL)) { return NULL; } @@ -1018,7 +1018,7 @@ njs_global_this_prop_handler(njs_vm_t *vm, njs_object_prop_t *prop, var_node.key = (uintptr_t) lhq.value; - rb_node = njs_rbtree_find(vm->variables_hash, &var_node.node); + rb_node = njs_rbtree_find(&vm->global_scope->variables, &var_node.node); if (rb_node == NULL) { return NJS_DECLINED; } diff --git a/src/njs_shell.c b/src/njs_shell.c index 25665795..4b4cedf2 100644 --- a/src/njs_shell.c +++ b/src/njs_shell.c @@ -1205,8 +1205,8 @@ njs_completion_generator(const char *text, int state) cmpl->length = njs_strlen(text); cmpl->suffix_completions = NULL; - if (vm->variables_hash != NULL) { - cmpl->node = njs_rbtree_min(vm->variables_hash); + if (vm->global_scope != NULL) { + cmpl->node = njs_rbtree_min(&vm->global_scope->variables); } } @@ -1214,7 +1214,8 @@ next: switch (cmpl->phase) { case NJS_COMPLETION_VAR: - variables = vm->variables_hash; + variables = (vm->global_scope != NULL) ? &vm->global_scope->variables + : NULL; if (variables == NULL) { njs_next_phase(cmpl); diff --git a/src/njs_vm.c b/src/njs_vm.c index 2f684e56..6e284010 100644 --- a/src/njs_vm.c +++ b/src/njs_vm.c @@ -228,7 +228,6 @@ njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end) njs_scope_value_set(vm, njs_scope_global_this_index(), &vm->global_value); vm->start = generator.code_start; - vm->variables_hash = &scope->variables; vm->global_scope = scope; if (vm->options.disassemble) { diff --git a/src/njs_vm.h b/src/njs_vm.h index d2b9a1d1..4ab3fbad 100644 --- a/src/njs_vm.h +++ b/src/njs_vm.h @@ -132,7 +132,6 @@ struct njs_vm_s { njs_native_frame_t *top_frame; njs_frame_t *active_frame; - njs_rbtree_t *variables_hash; njs_lvlhsh_t keywords_hash; njs_lvlhsh_t values_hash;