From e015b9da82556fc8d749ef4cf7c9d2e4e9f55879 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 14 Jun 2017 17:58:10 +0300 Subject: [PATCH] Using njs_string_get() where appropriate. --- njs/njs_object.c | 11 +---------- njs/njs_vm.c | 11 +---------- njs/njs_vm.h | 4 ++-- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/njs/njs_object.c b/njs/njs_object.c index 941130b5..c4163d4e 100644 --- a/njs/njs_object.c +++ b/njs/njs_object.c @@ -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; diff --git a/njs/njs_vm.c b/njs/njs_vm.c index 208aca0b..fedbcde0 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -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) { diff --git a/njs/njs_vm.h b/njs/njs_vm.h index 057920a9..af97fb8e 100644 --- a/njs/njs_vm.h +++ b/njs/njs_vm.h @@ -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) -- 2.47.3