]> git.kaiwu.me - njs.git/commitdiff
Modules: removed extra copying in shared dictionary.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 11 Jun 2024 06:06:26 +0000 (23:06 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Wed, 12 Jun 2024 21:53:47 +0000 (14:53 -0700)
 After 5730d5f pool copy is not needed because
 njs_vm_value_string_create() always create a copy.

nginx/ngx_js_shared_dict.c

index 330bd9bc9b721c392fc1c0fce7b1167bc7f4178e..19f6f4bd49d41587a8272fde27aff9bdc9d52203 100644 (file)
@@ -1440,23 +1440,13 @@ ngx_js_dict_copy_value_locked(njs_vm_t *vm, ngx_js_dict_t *dict,
     ngx_js_dict_node_t *node, njs_value_t *retval)
 {
     njs_int_t   ret;
-    njs_str_t   string;
     ngx_uint_t  type;
-    ngx_pool_t  *pool;
 
     type = dict->type;
 
     if (type == NGX_JS_DICT_TYPE_STRING) {
-        pool = ngx_external_pool(vm, njs_vm_external_ptr(vm));
-
-        string.length = node->u.value.len;
-        string.start = ngx_pstrdup(pool, &node->u.value);
-        if (string.start == NULL) {
-            return NGX_ERROR;
-        }
-
-        ret = njs_vm_value_string_create(vm, retval, string.start,
-                                         string.length);
+        ret = njs_vm_value_string_create(vm, retval, node->u.value.data,
+                                         node->u.value.len);
         if (ret != NJS_OK) {
             return NGX_ERROR;
         }