]> git.kaiwu.me - njs.git/commitdiff
Using njs_string_get() where appropriate.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 14 Jun 2017 14:58:10 +0000 (17:58 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 14 Jun 2017 14:58:10 +0000 (17:58 +0300)
njs/njs_object.c
njs/njs_vm.c
njs/njs_vm.h

index 941130b51cbe161ff7a97f00b494ffa2acdeb5ba..c4163d4e61c18ee06f00973591e55bb8f46e08ba 100644 (file)
@@ -109,16 +109,7 @@ njs_object_hash_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
     lhq.pool = vm->mem_cache_pool;
 
     do {
-        lhq.key.length = prop->name.short_string.size;
-
-        if (lhq.key.length != NJS_STRING_LONG) {
-            lhq.key.start = (u_char *) prop->name.short_string.start;
-
-        } else {
-            lhq.key.length = prop->name.data.string_size;
-            lhq.key.start = prop->name.data.u.string->start;
-        }
-
+        njs_string_get(&prop->name, &lhq.key);
         lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length);
         lhq.value = (void *) prop;
 
index 208aca0bf2ddf90d07f0af40f78a72248f4d0fc4..fedbcde02f3dabe4baae328c01e59c8ff202d83b 100644 (file)
@@ -1028,16 +1028,7 @@ njs_property_query(njs_vm_t *vm, njs_property_query_t *pq, njs_value_t *object,
 
         if (nxt_fast_path(ret == NXT_OK)) {
 
-            pq->lhq.key.length = pq->value.short_string.size;
-
-            if (pq->lhq.key.length != NJS_STRING_LONG) {
-                pq->lhq.key.start = pq->value.short_string.start;
-
-            } else {
-                pq->lhq.key.length = pq->value.data.string_size;
-                pq->lhq.key.start = pq->value.data.u.string->start;
-            }
-
+            njs_string_get(&pq->value, &pq->lhq.key);
             pq->lhq.key_hash = hash(pq->lhq.key.start, pq->lhq.key.length);
 
             if (obj == NULL) {
index 057920a9083db9581bb0c6a7b96b92d1d5def3b7..af97fb8ea0559c3a2812d579ac2c5226c393e875 100644 (file)
@@ -412,11 +412,11 @@ typedef njs_ret_t (*njs_vmcode_operation_t)(njs_vm_t *vm, njs_value_t *value1,
     do {                                                                      \
         if ((value)->short_string.size != NJS_STRING_LONG) {                  \
             (str)->length = (value)->short_string.size;                       \
-            (str)->start = (value)->short_string.start;                       \
+            (str)->start = (u_char *) (value)->short_string.start;            \
                                                                               \
         } else {                                                              \
             (str)->length = (value)->data.string_size;                        \
-            (str)->start = (value)->data.u.string->start;                     \
+            (str)->start = (u_char *) (value)->data.u.string->start;          \
         }                                                                     \
     } while (0)