From bacda147f04281355e980e1badbad122fc63f7b4 Mon Sep 17 00:00:00 2001 From: Aditi Date: Thu, 27 Mar 2025 00:26:46 +0530 Subject: [PATCH] src: update std::vector> to use v8::LocalVector Refs: https://github.com/nodejs/node/pull/57578 --- src/node_process_methods.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 3866c612600642..5c3505f25ab94f 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -50,6 +50,7 @@ using v8::HeapStatistics; using v8::Integer; using v8::Isolate; using v8::Local; +using v8::LocalVector; using v8::Maybe; using v8::NewStringType; using v8::Number; @@ -289,7 +290,7 @@ static void Uptime(const FunctionCallbackInfo& args) { static void GetActiveRequests(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - std::vector> request_v; + LocalVector request_v(env->isolate()); for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) { AsyncWrap* w = req_wrap->GetAsyncWrap(); if (w->persistent().IsEmpty()) @@ -306,7 +307,7 @@ static void GetActiveRequests(const FunctionCallbackInfo& args) { void GetActiveHandles(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - std::vector> handle_v; + LocalVector handle_v(env->isolate()); for (auto w : *env->handle_wrap_queue()) { if (!HandleWrap::HasRef(w)) continue; @@ -318,7 +319,7 @@ void GetActiveHandles(const FunctionCallbackInfo& args) { static void GetActiveResourcesInfo(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - std::vector> resources_info; + LocalVector resources_info(env->isolate()); // Active requests for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) { @@ -336,14 +337,17 @@ static void GetActiveResourcesInfo(const FunctionCallbackInfo& args) { } // Active timeouts - resources_info.insert(resources_info.end(), - env->timeout_info()[0], - FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout")); + Local timeout_str = FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout"); + for (int i = 0; i < env->timeout_info()[0]; ++i) { + resources_info.push_back(timeout_str); + } // Active immediates - resources_info.insert(resources_info.end(), - env->immediate_info()->ref_count(), - FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate")); + Local immediate_str = + FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate"); + for (uint32_t i = 0; i < env->immediate_info()->ref_count(); ++i) { + resources_info.push_back(immediate_str); + } args.GetReturnValue().Set( Array::New(env->isolate(), resources_info.data(), resources_info.size()));