From 68d7b6f87098416dc30fbb711fdff64fc2102809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Wed, 28 Jan 2026 23:22:05 -0300 Subject: [PATCH] sqlite: reserve vectors space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/61540 Reviewed-By: René Reviewed-By: Edy Silva Reviewed-By: Colin Ihrig Reviewed-By: Rafael Gonzaga --- src/node_sqlite.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index 4fad22c6189..ee8c1788c4b 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -322,6 +322,8 @@ class CustomAggregate { auto recv = Undefined(isolate); LocalVector js_argv(isolate); + js_argv.reserve(argc + 1); + js_argv.emplace_back(Local::New(isolate, agg->value)); for (int i = 0; i < argc; ++i) { @@ -625,6 +627,7 @@ void UserDefinedFunction::xFunc(sqlite3_context* ctx, auto recv = Undefined(isolate); auto fn = self->fn_.Get(isolate); LocalVector js_argv(isolate); + js_argv.reserve(argc); for (int i = 0; i < argc; ++i) { sqlite3_value* value = argv[i]; @@ -2063,18 +2066,16 @@ int DatabaseSync::AuthorizerCallback(void* user_data, CHECK(cb->IsFunction()); Local callback = cb.As(); - LocalVector js_argv(isolate); - // Convert SQLite authorizer parameters to JavaScript values - js_argv.emplace_back(Integer::New(isolate, action_code)); - js_argv.emplace_back( - NullableSQLiteStringToValue(isolate, param1).ToLocalChecked()); - js_argv.emplace_back( - NullableSQLiteStringToValue(isolate, param2).ToLocalChecked()); - js_argv.emplace_back( - NullableSQLiteStringToValue(isolate, param3).ToLocalChecked()); - js_argv.emplace_back( - NullableSQLiteStringToValue(isolate, param4).ToLocalChecked()); + LocalVector js_argv( + isolate, + { + Integer::New(isolate, action_code), + NullableSQLiteStringToValue(isolate, param1).ToLocalChecked(), + NullableSQLiteStringToValue(isolate, param2).ToLocalChecked(), + NullableSQLiteStringToValue(isolate, param3).ToLocalChecked(), + NullableSQLiteStringToValue(isolate, param4).ToLocalChecked(), + }); MaybeLocal retval = callback->Call( context, Undefined(isolate), js_argv.size(), js_argv.data());