Skip to content

Commit bb262a1

Browse files
Aditi-1400aduh95
authored andcommitted
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 2e34fc2 commit bb262a1

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/node_process_methods.cc

Lines changed: 13 additions & 9 deletions
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;
@@ -265,7 +266,7 @@ static void Uptime(const FunctionCallbackInfo<Value>& args) {
265266
static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
266267
Environment* env = Environment::GetCurrent(args);
267268

268-
std::vector<Local<Value>> request_v;
269+
LocalVector<Value> request_v(env->isolate());
269270
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
270271
AsyncWrap* w = req_wrap->GetAsyncWrap();
271272
if (w->persistent().IsEmpty())
@@ -282,7 +283,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
282283
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
283284
Environment* env = Environment::GetCurrent(args);
284285

285-
std::vector<Local<Value>> handle_v;
286+
LocalVector<Value> handle_v(env->isolate());
286287
for (auto w : *env->handle_wrap_queue()) {
287288
if (!HandleWrap::HasRef(w))
288289
continue;
@@ -294,7 +295,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
294295

295296
static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
296297
Environment* env = Environment::GetCurrent(args);
297-
std::vector<Local<Value>> resources_info;
298+
LocalVector<Value> resources_info(env->isolate());
298299

299300
// Active requests
300301
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
@@ -312,14 +313,17 @@ static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
312313
}
313314

314315
// Active timeouts
315-
resources_info.insert(resources_info.end(),
316-
env->timeout_info()[0],
317-
FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout"));
316+
Local<Value> timeout_str = FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout");
317+
for (int i = 0; i < env->timeout_info()[0]; ++i) {
318+
resources_info.push_back(timeout_str);
319+
}
318320

319321
// Active immediates
320-
resources_info.insert(resources_info.end(),
321-
env->immediate_info()->ref_count(),
322-
FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate"));
322+
Local<Value> immediate_str =
323+
FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate");
324+
for (uint32_t i = 0; i < env->immediate_info()->ref_count(); ++i) {
325+
resources_info.push_back(immediate_str);
326+
}
323327

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

0 commit comments

Comments
 (0)