Welcome! Log In Create A New Profile

Advanced

[njs] Making njs_value_property_i64() and njs_value_property_i64_set() fast.

Dmitry Volyntsev
January 12, 2022 01:02PM
details: https://hg.nginx.org/njs/rev/2adc0d3fc2bd
branches:
changeset: 1801:2adc0d3fc2bd
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Jan 12 17:58:19 2022 +0000
description:
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.

diffstat:

src/njs_value.h | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)

diffs (33 lines):

diff -r c786ef848004 -r 2adc0d3fc2bd src/njs_value.h
--- a/src/njs_value.h Wed Jan 12 17:58:18 2022 +0000
+++ b/src/njs_value.h Wed Jan 12 17:58:19 2022 +0000
@@ -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);
}
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Subject Author Views Posted

[njs] Making njs_value_property_i64() and njs_value_property_i64_set() fast.

Dmitry Volyntsev 293 January 12, 2022 01:02PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 184
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready