details: https://hg.nginx.org/njs/rev/27da19960b72
branches:
changeset: 2332:27da19960b72
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue May 21 23:38:19 2024 -0700
description:
Avoid creating byte strings explicitly.
Previously, calls like njs_string_new(,,,0) produced byte strings by
explicitly providing zero length argument.
diffstat:
src/njs_builtin.c | 4 ++--
src/njs_json.c | 8 +-------
src/njs_vm.c | 2 +-
3 files changed, 4 insertions(+), 10 deletions(-)
diffs (58 lines):
diff -r 286dbef3c0b2 -r 27da19960b72 src/njs_builtin.c
--- a/src/njs_builtin.c Mon May 20 16:44:10 2024 -0700
+++ b/src/njs_builtin.c Tue May 21 23:38:19 2024 -0700
@@ -388,7 +388,7 @@ njs_builtin_traverse(njs_vm_t *vm, njs_t
return NJS_ERROR;
}
- ret = njs_string_new(vm, &prop->name, buf, p - buf, 0);
+ ret = njs_string_create(vm, &prop->name, buf, p - buf);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
@@ -590,7 +590,7 @@ njs_ext_dump(njs_vm_t *vm, njs_value_t *
return NJS_ERROR;
}
- return njs_string_new(vm, retval, str.start, str.length, 0);
+ return njs_string_create(vm, retval, str.start, str.length);
}
diff -r 286dbef3c0b2 -r 27da19960b72 src/njs_json.c
--- a/src/njs_json.c Mon May 20 16:44:10 2024 -0700
+++ b/src/njs_json.c Tue May 21 23:38:19 2024 -0700
@@ -548,7 +548,6 @@ njs_json_parse_string(njs_json_parse_ctx
{
u_char ch, *s, *dst;
size_t size, surplus;
- ssize_t length;
uint32_t utf, utf_low;
njs_int_t ret;
const u_char *start, *last;
@@ -742,12 +741,7 @@ njs_json_parse_string(njs_json_parse_ctx
start = dst;
}
- length = njs_utf8_length(start, size);
- if (njs_slow_path(length < 0)) {
- length = 0;
- }
-
- ret = njs_string_new(ctx->vm, value, (u_char *) start, size, length);
+ ret = njs_string_create(ctx->vm, value, (u_char *) start, size);
if (njs_slow_path(ret != NJS_OK)) {
return NULL;
}
diff -r 286dbef3c0b2 -r 27da19960b72 src/njs_vm.c
--- a/src/njs_vm.c Mon May 20 16:44:10 2024 -0700
+++ b/src/njs_vm.c Tue May 21 23:38:19 2024 -0700
@@ -874,7 +874,7 @@ njs_vm_bind2(njs_vm_t *vm, const njs_str
njs_lvlhsh_t *hash;
njs_lvlhsh_query_t lhq;
- ret = njs_string_new(vm, &prop->name, var_name->start, var_name->length, 0);
+ ret = njs_string_create(vm, &prop->name, var_name->start, var_name->length);
if (njs_slow_path(ret != NJS_OK)) {
return NJS_ERROR;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel