[njs] Using njs_string_get() where appropriate.

Dmitry Volyntsev xeioex at nginx.com
Mon Jun 19 11:49:28 UTC 2017


details:   http://hg.nginx.org/njs/rev/7ed74a2e4c50
branches:  
changeset: 365:7ed74a2e4c50
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Jun 14 17:58:10 2017 +0300
description:
Using njs_string_get() where appropriate.

diffstat:

 njs/njs_object.c |  11 +----------
 njs/njs_vm.c     |  11 +----------
 njs/njs_vm.h     |   4 ++--
 3 files changed, 4 insertions(+), 22 deletions(-)

diffs (59 lines):

diff -r cf6b4a543eea -r 7ed74a2e4c50 njs/njs_object.c
--- a/njs/njs_object.c	Tue Jun 13 17:52:11 2017 +0300
+++ b/njs/njs_object.c	Wed Jun 14 17:58:10 2017 +0300
@@ -109,16 +109,7 @@ njs_object_hash_create(njs_vm_t *vm, nxt
     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;
 
diff -r cf6b4a543eea -r 7ed74a2e4c50 njs/njs_vm.c
--- a/njs/njs_vm.c	Tue Jun 13 17:52:11 2017 +0300
+++ b/njs/njs_vm.c	Wed Jun 14 17:58:10 2017 +0300
@@ -1028,16 +1028,7 @@ njs_property_query(njs_vm_t *vm, njs_pro
 
         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) {
diff -r cf6b4a543eea -r 7ed74a2e4c50 njs/njs_vm.h
--- a/njs/njs_vm.h	Tue Jun 13 17:52:11 2017 +0300
+++ b/njs/njs_vm.h	Wed Jun 14 17:58:10 2017 +0300
@@ -412,11 +412,11 @@ typedef njs_ret_t (*njs_vmcode_operation
     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)
 


More information about the nginx-devel mailing list