Skip to content

Commit e800f00

Browse files
authored
src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>
Refs: #57578 PR-URL: #57646 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ad3e835 commit e800f00

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/node_process_methods.cc

+13-9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ using v8::HeapStatistics;
5050
using v8::Integer;
5151
using v8::Isolate;
5252
using v8::Local;
53+
using v8::LocalVector;
5354
using v8::Maybe;
5455
using v8::NewStringType;
5556
using v8::Number;
@@ -289,7 +290,7 @@ static void Uptime(const FunctionCallbackInfo<Value>& args) {
289290
static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
290291
Environment* env = Environment::GetCurrent(args);
291292

292-
std::vector<Local<Value>> request_v;
293+
LocalVector<Value> request_v(env->isolate());
293294
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
294295
AsyncWrap* w = req_wrap->GetAsyncWrap();
295296
if (w->persistent().IsEmpty())
@@ -306,7 +307,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
306307
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
307308
Environment* env = Environment::GetCurrent(args);
308309

309-
std::vector<Local<Value>> handle_v;
310+
LocalVector<Value> handle_v(env->isolate());
310311
for (auto w : *env->handle_wrap_queue()) {
311312
if (!HandleWrap::HasRef(w))
312313
continue;
@@ -318,7 +319,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
318319

319320
static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
320321
Environment* env = Environment::GetCurrent(args);
321-
std::vector<Local<Value>> resources_info;
322+
LocalVector<Value> resources_info(env->isolate());
322323

323324
// Active requests
324325
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
@@ -336,14 +337,17 @@ static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
336337
}
337338

338339
// Active timeouts
339-
resources_info.insert(resources_info.end(),
340-
env->timeout_info()[0],
341-
FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout"));
340+
Local<Value> timeout_str = FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout");
341+
for (int i = 0; i < env->timeout_info()[0]; ++i) {
342+
resources_info.push_back(timeout_str);
343+
}
342344

343345
// Active immediates
344-
resources_info.insert(resources_info.end(),
345-
env->immediate_info()->ref_count(),
346-
FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate"));
346+
Local<Value> immediate_str =
347+
FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate");
348+
for (uint32_t i = 0; i < env->immediate_info()->ref_count(); ++i) {
349+
resources_info.push_back(immediate_str);
350+
}
347351

348352
args.GetReturnValue().Set(
349353
Array::New(env->isolate(), resources_info.data(), resources_info.size()));

0 commit comments

Comments
 (0)