]> git.kaiwu.me - njs.git/commitdiff
Using nxt_lvlhsh_each_init() where appropriate.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 13 Jun 2017 11:33:51 +0000 (14:33 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Tue, 13 Jun 2017 11:33:51 +0000 (14:33 +0300)
njs/njs_generator.c
njs/njs_object.c
njs/njs_variable.c
njs/njs_vm.c
nxt/test/lvlhsh_unit_test.c

index ceb40ae66bba3aca3ca6c93795616b30a3d5dcbf..16ee8baadf5c7f1abe808d649169c39c42575a80 100644 (file)
@@ -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);
index 844ad2a3cf53fd328fe73d6731eef9b63f778a6f..3313283c1f69d026564a36a98f1cf432396f631b 100644 (file)
@@ -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);
index 03a28e018ac9992136d0dedccf33466a3adc3317..59cd3188d55292029db655dbaeace2f50c56559c 100644 (file)
@@ -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;
 
index 5b3dcd5aa8ad13bcccac9cb5f79aa5ae3d948ec8..b712b369fd191b6d091f17095dca26d221688ffd 100644 (file)
@@ -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) {
index 40a554b237d19b439a775944487add379a35c5ae..b54cf97266c83496984a5e36c0043c1b8ef1ffd1 100644 (file)
@@ -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) {