From: Dmitry Volyntsev Date: Wed, 12 Jan 2022 17:58:19 +0000 (+0000) Subject: Making njs_value_property_i64() and njs_value_property_i64_set() fast. X-Git-Tag: 0.7.2~15 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=d225ff9cc157862fa2f69824b713ee7352c538f2;p=njs.git Making njs_value_property_i64() and njs_value_property_i64_set() fast. Since f5afb325896f (0.3.9) njs_value_property() and njs_value_property_set() have fast paths when key is a number. Passing key as a number eliminates conversion index to string and back. --- diff --git a/src/njs_value.h b/src/njs_value.h index 5dfb8e9d..12448eac 100644 --- a/src/njs_value.h +++ b/src/njs_value.h @@ -1080,13 +1080,9 @@ njs_inline njs_int_t njs_value_property_i64(njs_vm_t *vm, njs_value_t *value, int64_t index, njs_value_t *retval) { - njs_int_t ret; njs_value_t key; - ret = njs_int64_to_string(vm, &key, index); - if (njs_slow_path(ret != NJS_OK)) { - return ret; - } + njs_set_number(&key, index); return njs_value_property(vm, value, &key, retval); } @@ -1096,13 +1092,9 @@ njs_inline njs_int_t njs_value_property_i64_set(njs_vm_t *vm, njs_value_t *value, int64_t index, njs_value_t *setval) { - njs_int_t ret; njs_value_t key; - ret = njs_int64_to_string(vm, &key, index); - if (njs_slow_path(ret != NJS_OK)) { - return ret; - } + njs_set_number(&key, index); return njs_value_property_set(vm, value, &key, setval); }