Welcome! Log In Create A New Profile

Advanced

[njs] Moving njs_array_prototype_fill() to appropriate place.

April 04, 2017 06:26AM
details: http://hg.nginx.org/njs/rev/f62632793238
branches:
changeset: 336:f62632793238
user: Igor Sysoev <igor@sysoev.ru>
date: Tue Apr 04 11:00:49 2017 +0300
description:
Moving njs_array_prototype_fill() to appropriate place.

diffstat:

njs/njs_array.c | 126 ++++++++++++++++++++++++++++----------------------------
1 files changed, 63 insertions(+), 63 deletions(-)

diffs (143 lines):

diff -r a4e6f27ce598 -r f62632793238 njs/njs_array.c
--- a/njs/njs_array.c Tue Apr 04 10:56:33 2017 +0300
+++ b/njs/njs_array.c Tue Apr 04 11:00:49 2017 +0300
@@ -1214,6 +1214,69 @@ done:


static njs_ret_t
+njs_array_prototype_fill(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ nxt_int_t i, start, end, length;
+ njs_array_t *array;
+
+ vm->retval = args[0];
+
+ if (nargs < 2 || !njs_is_array(&args[0])) {
+ return NXT_OK;
+ }
+
+ array = args[0].data.u.array;
+ length = array->length;
+
+ if (length == 0) {
+ return NXT_OK;
+ }
+
+ start = 0;
+ end = length;
+
+ if (nargs > 2) {
+ start = args[2].data.u.number;
+
+ if (start > length) {
+ start = length;
+ }
+
+ if (start < 0) {
+ start += length;
+
+ if (start < 0) {
+ start = 0;
+ }
+ }
+
+ if (nargs > 3) {
+ end = args[3].data.u.number;
+
+ if (end > length) {
+ end = length;
+ }
+
+ if (end < 0) {
+ end += length;
+
+ if (end < 0) {
+ end = 0;
+ }
+ }
+ }
+ }
+
+ for (i = start; i < end; i++) {
+ array->start[i] = args[1];
+ }
+
+ return NXT_OK;
+}
+
+
+static njs_ret_t
njs_array_prototype_for_each(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
njs_index_t unused)
{
@@ -1352,69 +1415,6 @@ njs_array_prototype_every_continuation(n


static njs_ret_t
-njs_array_prototype_fill(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
- njs_index_t unused)
-{
- nxt_int_t i, start, end, length;
- njs_array_t *array;
-
- vm->retval = args[0];
-
- if (nargs < 2 || !njs_is_array(&args[0])) {
- return NXT_OK;
- }
-
- array = args[0].data.u.array;
- length = array->length;
-
- if (length == 0) {
- return NXT_OK;
- }
-
- start = 0;
- end = length;
-
- if (nargs > 2) {
- start = args[2].data.u.number;
-
- if (start > length) {
- start = length;
- }
-
- if (start < 0) {
- start += length;
-
- if (start < 0) {
- start = 0;
- }
- }
-
- if (nargs > 3) {
- end = args[3].data.u.number;
-
- if (end > length) {
- end = length;
- }
-
- if (end < 0) {
- end += length;
-
- if (end < 0) {
- end = 0;
- }
- }
- }
- }
-
- for (i = start; i < end; i++) {
- array->start[i] = args[1];
- }
-
- return NXT_OK;
-}
-
-
-static njs_ret_t
njs_array_prototype_filter(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
njs_index_t unused)
{
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Moving njs_array_prototype_fill() to appropriate place.

Igor Sysoev 469 April 04, 2017 06:26AM



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

Online Users

Guests: 69
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