[njs] Using nxt_lvlhsh_each_init() where appropriate.

Dmitry Volyntsev xeioex at nginx.com
Tue Jun 13 11:34:55 UTC 2017


details:   http://hg.nginx.org/njs/rev/096d526744d5
branches:  
changeset: 362:096d526744d5
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Jun 13 14:33:51 2017 +0300
description:
Using nxt_lvlhsh_each_init() where appropriate.

diffstat:

 njs/njs_generator.c         |  3 +--
 njs/njs_object.c            |  6 ++----
 njs/njs_variable.c          |  9 +++------
 njs/njs_vm.c                |  3 +--
 nxt/test/lvlhsh_unit_test.c |  3 +--
 5 files changed, 8 insertions(+), 16 deletions(-)

diffs (95 lines):

diff -r 499ed5aa4f98 -r 096d526744d5 njs/njs_generator.c
--- a/njs/njs_generator.c	Fri Jun 09 20:28:15 2017 +0300
+++ b/njs/njs_generator.c	Tue Jun 13 14:33:51 2017 +0300
@@ -2112,8 +2112,7 @@ njs_generate_argument_closures(njs_parse
         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 -r 499ed5aa4f98 -r 096d526744d5 njs/njs_object.c
--- a/njs/njs_object.c	Fri Jun 09 20:28:15 2017 +0300
+++ b/njs/njs_object.c	Tue Jun 13 14:33:51 2017 +0300
@@ -354,8 +354,7 @@ njs_object_keys(njs_vm_t *vm, njs_value_
         }
     }
 
-    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_
         }
     }
 
-    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 -r 499ed5aa4f98 -r 096d526744d5 njs/njs_variable.c
--- a/njs/njs_variable.c	Fri Jun 09 20:28:15 2017 +0300
+++ b/njs/njs_variable.c	Tue Jun 13 14:33:51 2017 +0300
@@ -245,8 +245,7 @@ njs_variables_scope_reference(njs_vm_t *
             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 -r 499ed5aa4f98 -r 096d526744d5 njs/njs_vm.c
--- a/njs/njs_vm.c	Fri Jun 09 20:28:15 2017 +0300
+++ b/njs/njs_vm.c	Tue Jun 13 14:33:51 2017 +0300
@@ -1207,8 +1207,7 @@ njs_vmcode_property_foreach(njs_vm_t *vm
 
         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 -r 499ed5aa4f98 -r 096d526744d5 nxt/test/lvlhsh_unit_test.c
--- a/nxt/test/lvlhsh_unit_test.c	Fri Jun 09 20:28:15 2017 +0300
+++ b/nxt/test/lvlhsh_unit_test.c	Tue Jun 13 14:33:51 2017 +0300
@@ -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) {


More information about the nginx-devel mailing list