Welcome! Log In Create A New Profile

Advanced

[njs] Simplified working with global value.

Dmitry Volyntsev
February 29, 2024 12:02PM
details: https://hg.nginx.org/njs/rev/e73d4947372d
branches:
changeset: 2291:e73d4947372d
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Feb 27 23:24:55 2024 -0800
description:
Simplified working with global value.

diffstat:

src/njs_builtin.c | 6 ++----
src/njs_function.c | 2 +-
src/njs_vm.c | 4 +---
3 files changed, 4 insertions(+), 8 deletions(-)

diffs (63 lines):

diff -r cb3e068a511c -r e73d4947372d src/njs_builtin.c
--- a/src/njs_builtin.c Thu Feb 22 20:25:43 2024 -0800
+++ b/src/njs_builtin.c Tue Feb 27 23:24:55 2024 -0800
@@ -258,8 +258,6 @@ njs_builtin_objects_create(njs_vm_t *vm)
vm->global_object = shared->objects[0];
vm->global_object.shared = 0;

- njs_set_object(&vm->global_value, &vm->global_object);
-
string_object = &shared->string_object;
njs_lvlhsh_init(&string_object->hash);
string_object->shared_hash = shared->string_instance_hash;
@@ -442,7 +440,7 @@ njs_builtin_completions(njs_vm_t *vm)
ctx.type = NJS_BUILTIN_TRAVERSE_KEYS;
njs_lvlhsh_init(&ctx.keys);

- ret = njs_object_traverse(vm, &vm->global_object, &ctx,
+ ret = njs_object_traverse(vm, njs_object(&vm->global_value), &ctx,
njs_builtin_traverse);
if (njs_slow_path(ret != NJS_OK)) {
return NULL;
@@ -753,7 +751,7 @@ njs_builtin_match_native_function(njs_vm

ctx.match = njs_str_value("");

- ret = njs_object_traverse(vm, &vm->global_object, &ctx,
+ ret = njs_object_traverse(vm, njs_object(&vm->global_value), &ctx,
njs_builtin_traverse);

if (ret == NJS_DONE) {
diff -r cb3e068a511c -r e73d4947372d src/njs_function.c
--- a/src/njs_function.c Thu Feb 22 20:25:43 2024 -0800
+++ b/src/njs_function.c Tue Feb 27 23:24:55 2024 -0800
@@ -435,7 +435,7 @@ njs_function_lambda_frame(njs_vm_t *vm,
if (njs_slow_path(function->global_this
&& njs_is_null_or_undefined(this)))
{
- njs_set_object(native_frame->local[0], &vm->global_object);
+ njs_value_assign(native_frame->local[0], &vm->global_value);
}

/* Copy arguments. */
diff -r cb3e068a511c -r e73d4947372d src/njs_vm.c
--- a/src/njs_vm.c Thu Feb 22 20:25:43 2024 -0800
+++ b/src/njs_vm.c Tue Feb 27 23:24:55 2024 -0800
@@ -425,8 +425,6 @@ njs_vm_clone(njs_vm_t *vm, njs_external_

nvm->levels[NJS_LEVEL_GLOBAL] = global;

- njs_set_object(&nvm->global_value, &nvm->global_object);
-
/* globalThis and this */
njs_scope_value_set(nvm, njs_scope_global_this_index(), &nvm->global_value);

@@ -826,7 +824,7 @@ njs_vm_value(njs_vm_t *vm, const njs_str
start = path->start;
end = start + path->length;

- njs_set_object(&value, &vm->global_object);
+ njs_value_assign(&value, &vm->global_value);

for ( ;; ) {
p = njs_strlchr(start, end, '.');
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Simplified working with global value.

Dmitry Volyntsev 246 February 29, 2024 12:02PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 183
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready