Skip to content

Commit ccc3bb7

Browse files
joyeecheungBridgeAR
authored andcommitted
process: remove pushValueToArray in GetActiveHandles
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent ba4337d commit ccc3bb7

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/node_process.cc

+4-16
Original file line numberDiff line numberDiff line change
@@ -813,26 +813,14 @@ void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
813813
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
814814
Environment* env = Environment::GetCurrent(args);
815815

816-
Local<Array> ary = Array::New(env->isolate());
817-
Local<Context> ctx = env->context();
818-
Local<Function> fn = env->push_values_to_array_function();
819-
Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX];
820-
size_t idx = 0;
821-
816+
std::vector<Local<Value>> handle_v;
822817
for (auto w : *env->handle_wrap_queue()) {
823818
if (!HandleWrap::HasRef(w))
824819
continue;
825-
argv[idx] = w->GetOwner();
826-
if (++idx >= arraysize(argv)) {
827-
fn->Call(ctx, ary, idx, argv).ToLocalChecked();
828-
idx = 0;
829-
}
830-
}
831-
if (idx > 0) {
832-
fn->Call(ctx, ary, idx, argv).ToLocalChecked();
820+
handle_v.push_back(w->GetOwner());
833821
}
834-
835-
args.GetReturnValue().Set(ary);
822+
args.GetReturnValue().Set(
823+
Array::New(env->isolate(), handle_v.data(), handle_v.size()));
836824
}
837825

838826
void DebugPortGetter(Local<Name> property,

0 commit comments

Comments
 (0)