[njs] Moved njs_string_offset_map_init() closer to its usage.

Valentin Bartenev vbart at nginx.com
Thu Nov 10 16:18:28 UTC 2016


details:   http://hg.nginx.org/njs/rev/0939df226d5c
branches:  
changeset: 251:0939df226d5c
user:      Valentin Bartenev <vbart at nginx.com>
date:      Thu Nov 10 19:09:13 2016 +0300
description:
Moved njs_string_offset_map_init() closer to its usage.

No functional changes.

diffstat:

 njs/njs_string.c |  58 ++++++++++++++++++++++++++++----------------------------
 njs/njs_string.h |   2 +-
 2 files changed, 30 insertions(+), 30 deletions(-)

diffs (94 lines):

diff -r adf61ca4267b -r 0939df226d5c njs/njs_string.c
--- a/njs/njs_string.c	Thu Nov 10 18:54:28 2016 +0300
+++ b/njs/njs_string.c	Thu Nov 10 19:09:13 2016 +0300
@@ -466,35 +466,6 @@ njs_string_prototype_length(njs_vm_t *vm
 }
 
 
-nxt_noinline void
-njs_string_offset_map_init(const u_char *start, size_t size)
-{
-    size_t        offset;
-    uint32_t      *map;
-    nxt_uint_t    n;
-    const u_char  *p, *end;
-
-    end = start + size;
-    map = njs_string_map_start(end);
-    p = start;
-    n = 0;
-    offset = NJS_STRING_MAP_STRIDE;
-
-    do {
-        if (offset == 0) {
-            map[n++] = p - start;
-            offset = NJS_STRING_MAP_STRIDE;
-        }
-
-        /* The UTF-8 string should be valid since its length is known. */
-        p = nxt_utf8_next(p, end);
-
-        offset--;
-
-    } while (p < end);
-}
-
-
 nxt_bool_t
 njs_string_eq(const njs_value_t *v1, const njs_value_t *v2)
 {
@@ -1588,6 +1559,35 @@ njs_string_index(njs_string_prop_t *stri
 }
 
 
+nxt_noinline void
+njs_string_offset_map_init(const u_char *start, size_t size)
+{
+    size_t        offset;
+    uint32_t      *map;
+    nxt_uint_t    n;
+    const u_char  *p, *end;
+
+    end = start + size;
+    map = njs_string_map_start(end);
+    p = start;
+    n = 0;
+    offset = NJS_STRING_MAP_STRIDE;
+
+    do {
+        if (offset == 0) {
+            map[n++] = p - start;
+            offset = NJS_STRING_MAP_STRIDE;
+        }
+
+        /* The UTF-8 string should be valid since its length is known. */
+        p = nxt_utf8_next(p, end);
+
+        offset--;
+
+    } while (p < end);
+}
+
+
 /*
  * String.toLowerCase().
  * The method supports only simple folding.  For example, Turkish "İ"
diff -r adf61ca4267b -r 0939df226d5c njs/njs_string.h
--- a/njs/njs_string.h	Thu Nov 10 18:54:28 2016 +0300
+++ b/njs/njs_string.h	Thu Nov 10 19:09:13 2016 +0300
@@ -128,7 +128,6 @@ nxt_noinline size_t njs_string_prop(njs_
     njs_value_t *value);
 njs_ret_t njs_string_constructor(njs_vm_t *vm, njs_value_t *args,
     nxt_uint_t nargs, njs_index_t unused);
-void njs_string_offset_map_init(const u_char *start, size_t size);
 nxt_bool_t njs_string_eq(const njs_value_t *val1, const njs_value_t *val2);
 nxt_int_t njs_string_cmp(const njs_value_t *val1, const njs_value_t *val2);
 njs_ret_t njs_string_slice(njs_vm_t *vm, njs_value_t *dst,
@@ -137,6 +136,7 @@ const u_char *njs_string_offset(const u_
     size_t index);
 nxt_noinline uint32_t njs_string_index(njs_string_prop_t *string,
     uint32_t offset);
+void njs_string_offset_map_init(const u_char *start, size_t size);
 njs_ret_t njs_primitive_value_to_string(njs_vm_t *vm, njs_value_t *dst,
     const njs_value_t *src);
 double njs_string_to_number(njs_value_t *value, nxt_bool_t exact);


More information about the nginx-devel mailing list