From: Dmitry Volyntsev Date: Wed, 4 Oct 2023 20:35:38 +0000 (-0700) Subject: Improved memory footprint of RegExp.prototype.split(). X-Git-Tag: 0.8.2~10 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=aa697e3e98b479f8e62d756512f5b6db427b7a84;p=njs.git Improved memory footprint of RegExp.prototype.split(). --- diff --git a/src/njs_regexp.c b/src/njs_regexp.c index 47a32375..b6c86dba 100644 --- a/src/njs_regexp.c +++ b/src/njs_regexp.c @@ -1773,6 +1773,10 @@ njs_regexp_prototype_symbol_split(njs_vm_t *vm, njs_value_t *args, e = njs_min(e, length); if (e == p) { + if (njs_object_slots(&z)) { + njs_regexp_exec_result_free(vm, njs_array(&z)); + } + q = q + 1; continue; } @@ -1794,6 +1798,10 @@ njs_regexp_prototype_symbol_split(njs_vm_t *vm, njs_value_t *args, } if (array->length == limit) { + if (njs_object_slots(&z)) { + njs_regexp_exec_result_free(vm, njs_array(&z)); + } + goto done; } @@ -1818,10 +1826,18 @@ njs_regexp_prototype_symbol_split(njs_vm_t *vm, njs_value_t *args, } if (array->length == limit) { + if (njs_object_slots(&z)) { + njs_regexp_exec_result_free(vm, njs_array(&z)); + } + goto done; } } + if (njs_object_slots(&z)) { + njs_regexp_exec_result_free(vm, njs_array(&z)); + } + q = p; }