details:   https://hg.nginx.org/njs/rev/107c7098bd6d
branches:  
changeset: 2067:107c7098bd6d
user:      Dmitry Volyntsev <xei...@nginx.com>
date:      Tue Mar 07 20:38:08 2023 -0800
description:
Making njs_string_prop() a macro.

diffstat:

 src/njs_string.c |  25 -------------------------
 src/njs_string.h |  26 +++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 26 deletions(-)

diffs (78 lines):

diff -r 8170f061bbde -r 107c7098bd6d src/njs_string.c
--- a/src/njs_string.c  Tue Mar 07 20:35:00 2023 -0800
+++ b/src/njs_string.c  Tue Mar 07 20:38:08 2023 -0800
@@ -566,31 +566,6 @@ njs_string_validate(njs_vm_t *vm, njs_st
 }
 
 
-size_t
-njs_string_prop(njs_string_prop_t *string, const njs_value_t *value)
-{
-    size_t     size;
-    uintptr_t  length;
-
-    size = value->short_string.size;
-
-    if (size != NJS_STRING_LONG) {
-        string->start = (u_char *) value->short_string.start;
-        length = value->short_string.length;
-
-    } else {
-        string->start = (u_char *) value->long_string.data->start;
-        size = value->long_string.size;
-        length = value->long_string.data->length;
-    }
-
-    string->size = size;
-    string->length = length;
-
-    return (length == 0) ? size : length;
-}
-
-
 static njs_int_t
 njs_string_constructor(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t unused)
diff -r 8170f061bbde -r 107c7098bd6d src/njs_string.h
--- a/src/njs_string.h  Tue Mar 07 20:35:00 2023 -0800
+++ b/src/njs_string.h  Tue Mar 07 20:38:08 2023 -0800
@@ -237,7 +237,6 @@ uint32_t njs_string_trim(const njs_value
 void njs_string_copy(njs_value_t *dst, njs_value_t *src);
 njs_int_t njs_string_validate(njs_vm_t *vm, njs_string_prop_t *string,
     njs_value_t *value);
-size_t njs_string_prop(njs_string_prop_t *string, const njs_value_t *value);
 njs_int_t njs_string_cmp(const njs_value_t *val1, const njs_value_t *val2);
 void njs_string_slice_string_prop(njs_string_prop_t *dst,
     const njs_string_prop_t *string, const njs_slice_prop_t *slice);
@@ -280,6 +279,31 @@ njs_string_offset(njs_string_prop_t *str
 }
 
 
+njs_inline size_t
+njs_string_prop(njs_string_prop_t *string, const njs_value_t *value)
+{
+    size_t     size;
+    uintptr_t  length;
+
+    size = value->short_string.size;
+
+    if (size != NJS_STRING_LONG) {
+        string->start = (u_char *) value->short_string.start;
+        length = value->short_string.length;
+
+    } else {
+        string->start = (u_char *) value->long_string.data->start;
+        size = value->long_string.size;
+        length = value->long_string.data->length;
+    }
+
+    string->size = size;
+    string->length = length;
+
+    return (length == 0) ? size : length;
+}
+
+
 extern const njs_object_init_t  njs_string_instance_init;
 extern const njs_object_type_init_t  njs_string_type_init;
 
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to