]> git.kaiwu.me - njs.git/commitdiff
Improved njs_object_enumerate().
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 28 Mar 2019 17:42:11 +0000 (20:42 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 28 Mar 2019 17:42:11 +0000 (20:42 +0300)
njs/njs_object.c

index b2f69fbbba4615d394f7f510c9ef06cf88c73609..8ceb7d93c2f92e647a914fdf9a9965059bce90a6 100644 (file)
@@ -1217,10 +1217,11 @@ njs_object_enumerate(njs_vm_t *vm, const njs_value_t *value,
     if (nxt_fast_path(properties != 0)) {
         nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
 
+        hash = &value->data.u.object->hash;
+
         switch (kind) {
 
         case NJS_ENUM_KEYS:
-            hash = &value->data.u.object->hash;
             for ( ;; ) {
                 prop = nxt_lvlhsh_each(hash, &lhe);
 
@@ -1251,7 +1252,6 @@ njs_object_enumerate(njs_vm_t *vm, const njs_value_t *value,
             break;
 
         case NJS_ENUM_VALUES:
-            hash = &value->data.u.object->hash;
             for ( ;; ) {
                 prop = nxt_lvlhsh_each(hash, &lhe);