[njs] Removed deprecated njs_string_set().

noreply at nginx.com noreply at nginx.com
Tue Oct 8 04:35:02 UTC 2024


details:   https://github.com/nginx/njs/commit/cf889c11f2fca991452dbdc7fe40cc4e05b708d4
branches:  master
commit:    cf889c11f2fca991452dbdc7fe40cc4e05b708d4
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon, 7 Oct 2024 18:51:03 -0700
description:
Removed deprecated njs_string_set().


---
 src/njs_string.c         | 52 ------------------------------------------------
 src/njs_string.h         |  3 ---
 src/test/njs_benchmark.c | 27 +------------------------
 3 files changed, 1 insertion(+), 81 deletions(-)

diff --git a/src/njs_string.c b/src/njs_string.c
index ea22755b..9405a8db 100644
--- a/src/njs_string.c
+++ b/src/njs_string.c
@@ -74,58 +74,6 @@ static njs_int_t njs_string_match_multiple(njs_vm_t *vm, njs_value_t *args,
 #define njs_base64_decoded_length(len, pad)  (((len / 4) * 3) - pad)
 
 
-njs_int_t
-njs_string_set(njs_vm_t *vm, njs_value_t *value, const u_char *start,
-    uint32_t size)
-{
-    u_char        *dst;
-    const u_char  *src;
-    njs_string_t  *string;
-
-    value->type = NJS_STRING;
-    njs_string_truth(value, size);
-
-    if (size <= NJS_STRING_SHORT) {
-        value->short_string.size = size;
-        value->short_string.length = 0;
-
-        dst = value->short_string.start;
-        src = start;
-
-        while (size != 0) {
-            /* The maximum size is just 14 bytes. */
-            njs_pragma_loop_disable_vectorization;
-
-            *dst++ = *src++;
-            size--;
-        }
-
-    } else {
-        /*
-         * Setting UTF-8 length is not required here, it just allows
-         * to store the constant in whole byte instead of bit twiddling.
-         */
-        value->short_string.size = NJS_STRING_LONG;
-        value->short_string.length = 0;
-        value->long_string.external = 0xff;
-        value->long_string.size = size;
-
-        string = njs_mp_alloc(vm->mem_pool, sizeof(njs_string_t));
-        if (njs_slow_path(string == NULL)) {
-            njs_memory_error(vm);
-            return NJS_ERROR;
-        }
-
-        value->long_string.data = string;
-
-        string->start = (u_char *) start;
-        string->length = 0;
-    }
-
-    return NJS_OK;
-}
-
-
 njs_int_t
 njs_string_create(njs_vm_t *vm, njs_value_t *value, const u_char *src,
     size_t size)
diff --git a/src/njs_string.h b/src/njs_string.h
index 9b478875..686a5a74 100644
--- a/src/njs_string.h
+++ b/src/njs_string.h
@@ -102,9 +102,6 @@ typedef enum {
 } njs_trim_t;
 
 
-/* njs_string_set() Is deprecated. */
-njs_int_t njs_string_set(njs_vm_t *vm, njs_value_t *value, const u_char *start,
-    uint32_t size);
 u_char *njs_string_alloc(njs_vm_t *vm, njs_value_t *value, uint64_t size,
     uint64_t length);
 njs_int_t njs_string_new(njs_vm_t *vm, njs_value_t *value, const u_char *start,
diff --git a/src/test/njs_benchmark.c b/src/test/njs_benchmark.c
index f957dc56..71de6b57 100644
--- a/src/test/njs_benchmark.c
+++ b/src/test/njs_benchmark.c
@@ -265,26 +265,6 @@ static njs_benchmark_test_t  njs_test[] =
       njs_str("4"),
       100000 },
 
-    { "string set 'abcdefABCDEF'",
-      njs_str("benchmark.string('set', 'abcdef', 1000000)"),
-      njs_str("undefined"),
-      1 },
-
-    { "string set 'АБВГДЕ'",
-      njs_str("benchmark.string('set', 'АБВГДЕ', 1000000)"),
-      njs_str("undefined"),
-      1 },
-
-    { "string set 'x'.repeat(24)",
-      njs_str("benchmark.string('set', 'x'.repeat(32), 1000000)"),
-      njs_str("undefined"),
-      1 },
-
-    { "string set 'Д'.repeat(12)",
-      njs_str("benchmark.string('set', 'А'.repeat(16), 1000000)"),
-      njs_str("undefined"),
-      1 },
-
     { "string create 'abcdefABCDEF'",
       njs_str("benchmark.string('create', 'abcdef', 1000000)"),
       njs_str("undefined"),
@@ -723,12 +703,7 @@ njs_benchmark_string(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
         return NJS_ERROR;
     }
 
-    if (memcmp(mode.start, "set", 3) == 0) {
-        for (i = 0; i < n; i++) {
-            njs_string_set(vm, &value, s.start, s.length);
-        }
-
-    } else if (memcmp(mode.start, "create", 6) == 0) {
+    if (memcmp(mode.start, "create", 6) == 0) {
 
         for (i = 0; i < n; i++) {
             njs_string_create(vm, &value, s.start, s.length);


More information about the nginx-devel mailing list