[njs] Moving njs_array_prototype_fill() to appropriate place.

Igor Sysoev igor at sysoev.ru
Tue Apr 4 10:24:43 UTC 2017


details:   http://hg.nginx.org/njs/rev/f62632793238
branches:  
changeset: 336:f62632793238
user:      Igor Sysoev <igor at 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)
 {


More information about the nginx-devel mailing list