From: Dmitry Volyntsev Date: Tue, 13 Jun 2017 11:33:51 +0000 (+0300) Subject: Using nxt_lvlhsh_each_init() where appropriate. X-Git-Tag: 0.1.11~17 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=04e22487d8ec78b17b0f5c2b949016327ee14eb9;p=njs.git Using nxt_lvlhsh_each_init() where appropriate. --- diff --git a/njs/njs_generator.c b/njs/njs_generator.c index ceb40ae6..16ee8baa 100644 --- a/njs/njs_generator.c +++ b/njs/njs_generator.c @@ -2112,8 +2112,7 @@ njs_generate_argument_closures(njs_parser_t *parser, njs_parser_node_t *node) return; } - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &njs_variables_hash_proto; + nxt_lvlhsh_each_init(&lhe, &njs_variables_hash_proto); do { var = nxt_lvlhsh_each(&node->scope->variables, &lhe); diff --git a/njs/njs_object.c b/njs/njs_object.c index 844ad2a3..3313283c 100644 --- a/njs/njs_object.c +++ b/njs/njs_object.c @@ -354,8 +354,7 @@ njs_object_keys(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, } } - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &njs_object_hash_proto; + nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto); hash = &args[1].data.u.object->hash; @@ -391,8 +390,7 @@ njs_object_keys(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, } } - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &njs_object_hash_proto; + nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto); for ( ;; ) { prop = nxt_lvlhsh_each(hash, &lhe); diff --git a/njs/njs_variable.c b/njs/njs_variable.c index 03a28e01..59cd3188 100644 --- a/njs/njs_variable.c +++ b/njs/njs_variable.c @@ -245,8 +245,7 @@ njs_variables_scope_reference(njs_vm_t *vm, njs_parser_scope_t *scope) return NXT_ERROR; } - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &njs_variables_hash_proto; + nxt_lvlhsh_each_init(&lhe, &njs_variables_hash_proto); for ( ;; ) { node = nxt_lvlhsh_each(&scope->references, &lhe); @@ -501,8 +500,7 @@ njs_vm_export_functions(njs_vm_t *vm) n = 1; - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &njs_variables_hash_proto; + nxt_lvlhsh_each_init(&lhe, &njs_variables_hash_proto); for ( ;; ) { var = nxt_lvlhsh_each(&vm->variables_hash, &lhe); @@ -522,8 +520,7 @@ njs_vm_export_functions(njs_vm_t *vm) return NULL; } - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &njs_variables_hash_proto; + nxt_lvlhsh_each_init(&lhe, &njs_variables_hash_proto); ex = export; diff --git a/njs/njs_vm.c b/njs/njs_vm.c index 5b3dcd5a..b712b369 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -1207,8 +1207,7 @@ njs_vmcode_property_foreach(njs_vm_t *vm, njs_value_t *object, vm->retval.data.u.next = next; - memset(&next->lhe, 0, sizeof(nxt_lvlhsh_each_t)); - next->lhe.proto = &njs_object_hash_proto; + nxt_lvlhsh_each_init(&next->lhe, &njs_object_hash_proto); next->index = -1; if (njs_is_array(object) && object->data.u.array->length != 0) { diff --git a/nxt/test/lvlhsh_unit_test.c b/nxt/test/lvlhsh_unit_test.c index 40a554b2..b54cf972 100644 --- a/nxt/test/lvlhsh_unit_test.c +++ b/nxt/test/lvlhsh_unit_test.c @@ -236,8 +236,7 @@ lvlhsh_unit_test(nxt_uint_t n) } } - memset(&lhe, 0, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &lvlhsh_proto; + nxt_lvlhsh_each_init(&lhe, &lvlhsh_proto); for (i = 0; i < n + 1; i++) { if (nxt_lvlhsh_each(&lh, &lhe) == NULL) {