From: Dmitry Volyntsev Date: Thu, 14 Aug 2025 06:19:46 +0000 (-0700) Subject: Modules: removing extra copy while streaming in qjs. X-Git-Tag: 0.9.2~13 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=6842e1b8f2cf73243afdcb88b27d08fdaa861ad6;p=njs.git Modules: removing extra copy while streaming in qjs. --- diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 402c7382..487c8115 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -7398,7 +7398,6 @@ ngx_http_qjs_body_filter(ngx_http_request_t *r, ngx_http_js_loc_conf_t *jlcf, ngx_http_js_ctx_t *ctx, ngx_chain_t *in) { size_t len; - u_char *p; JSAtom last_key; JSValue arguments[3], last; ngx_int_t rc; @@ -7425,16 +7424,7 @@ ngx_http_qjs_body_filter(ngx_http_request_t *r, ngx_http_js_loc_conf_t *jlcf, if (!ctx->done) { len = b->last - b->pos; - p = ngx_pnalloc(r->pool, len); - if (p == NULL) { - return NJS_ERROR; - } - - if (len) { - ngx_memcpy(p, b->pos, len); - } - - arguments[1] = ngx_qjs_prop(cx, jlcf->buffer_type, p, len); + arguments[1] = ngx_qjs_prop(cx, jlcf->buffer_type, b->pos, len); if (JS_IsException(arguments[1])) { JS_FreeAtom(cx, last_key); return NGX_ERROR; diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c index a3a85662..a7446c49 100644 --- a/nginx/ngx_stream_js_module.c +++ b/nginx/ngx_stream_js_module.c @@ -2638,7 +2638,6 @@ ngx_stream_qjs_run_event(ngx_stream_session_t *s, ngx_stream_js_ctx_t *ctx, ngx_stream_js_ev_t *event, ngx_uint_t from_upstream) { size_t len; - u_char *p; JSContext *cx; ngx_int_t rc; ngx_str_t exception; @@ -2658,17 +2657,7 @@ ngx_stream_qjs_run_event(ngx_stream_session_t *s, ngx_stream_js_ctx_t *ctx, len = b ? b->last - b->pos : 0; - p = ngx_pnalloc(c->pool, len); - if (p == NULL) { - (void) JS_ThrowOutOfMemory(cx); - goto error; - } - - if (len) { - ngx_memcpy(p, b->pos, len); - } - - argv[0] = ngx_qjs_prop(cx, event->data_type, p, len); + argv[0] = ngx_qjs_prop(cx, event->data_type, b ? b->pos : NULL, len); if (JS_IsException(argv[0])) { goto error; }