Welcome! Log In Create A New Profile

Advanced

[njs] Introduced njs_array_push().

Dmitry Volyntsev
June 09, 2020 12:50PM
details: https://hg.nginx.org/njs/rev/724dedc6be18
branches:
changeset: 1428:724dedc6be18
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Jun 09 12:56:56 2020 +0000
description:
Introduced njs_array_push().

diffstat:

src/njs_array.h | 14 ++++++++++++++
src/njs_vm.c | 12 +-----------
2 files changed, 15 insertions(+), 11 deletions(-)

diffs (51 lines):

diff -r 857c2166d10b -r 724dedc6be18 src/njs_array.h
--- a/src/njs_array.h Sat Jun 06 18:15:07 2020 +0300
+++ b/src/njs_array.h Tue Jun 09 12:56:56 2020 +0000
@@ -35,6 +35,20 @@ njs_int_t njs_array_prototype_to_string(
njs_uint_t nargs, njs_index_t unused);


+njs_inline njs_value_t *
+njs_array_push(njs_vm_t *vm, njs_array_t *array)
+{
+ njs_int_t ret;
+
+ ret = njs_array_expand(vm, array, 0, 1);
+ if (njs_slow_path(ret != NJS_OK)) {
+ return NULL;
+ }
+
+ return &array->start[array->length++];
+}
+
+
extern const njs_object_init_t njs_array_instance_init;
extern const njs_object_type_init_t njs_array_type_init;

diff -r 857c2166d10b -r 724dedc6be18 src/njs_vm.c
--- a/src/njs_vm.c Sat Jun 06 18:15:07 2020 +0300
+++ b/src/njs_vm.c Tue Jun 09 12:56:56 2020 +0000
@@ -934,22 +934,12 @@ njs_vm_array_alloc(njs_vm_t *vm, njs_val
njs_value_t *
njs_vm_array_push(njs_vm_t *vm, njs_value_t *value)
{
- njs_int_t ret;
- njs_array_t *array;
-
if (njs_slow_path(!njs_is_array(value))) {
njs_type_error(vm, "njs_vm_array_push() argument is not array");
return NULL;
}

- array = njs_array(value);
-
- ret = njs_array_expand(vm, array, 0, 1);
- if (njs_slow_path(ret != NJS_OK)) {
- return NULL;
- }
-
- return &array->start[array->length++];
+ return njs_array_push(vm, njs_array(value));
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Introduced njs_array_push().

Dmitry Volyntsev 85 June 09, 2020 12:50PM



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

Online Users

Guests: 67
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready