Welcome! Log In Create A New Profile

Advanced

[njs] Optimized string creation with ASCII input.

Dmitry Volyntsev
May 18, 2024 12:56AM
details: https://hg.nginx.org/njs/rev/dec46ad52e9a
branches:
changeset: 2328:dec46ad52e9a
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Fri May 17 21:54:49 2024 -0700
description:
Optimized string creation with ASCII input.

diffstat:

src/njs_string.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r f474755a4dce -r dec46ad52e9a src/njs_string.c
--- a/src/njs_string.c Fri May 17 18:36:12 2024 -0700
+++ b/src/njs_string.c Fri May 17 21:54:49 2024 -0700
@@ -130,8 +130,20 @@ njs_int_t
njs_string_create(njs_vm_t *vm, njs_value_t *value, const char *src,
size_t size)
{
+ u_char *p, *p_end;
njs_str_t str;

+ p = (u_char *) src;
+ p_end = p + size;
+
+ while (p < p_end && *p < 0x80) {
+ p++;
+ }
+
+ if (p == p_end) {
+ return njs_string_new(vm, value, (u_char *) src, size, size);
+ }
+
str.start = (u_char *) src;
str.length = size;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Optimized string creation with ASCII input.

Dmitry Volyntsev 189 May 18, 2024 12:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 70
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready