Skip to content

Commit ba4337d

Browse files
joyeecheungBridgeAR
authored andcommitted
process: remove pushValueToArray in GetActiveRequests
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 e588846 commit ba4337d

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
@@ -797,29 +797,17 @@ void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
797797
Environment* env = Environment::GetCurrent(args);
798798

799799
Local<Array> ary = Array::New(args.GetIsolate());
800-
Local<Context> ctx = env->context();
801-
Local<Function> fn = env->push_values_to_array_function();
802-
Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX];
803-
size_t idx = 0;
804-
800+
std::vector<Local<Value>> request_v;
805801
for (auto w : *env->req_wrap_queue()) {
806802
if (w->persistent().IsEmpty())
807803
continue;
808-
argv[idx] = w->GetOwner();
809-
if (++idx >= arraysize(argv)) {
810-
fn->Call(ctx, ary, idx, argv).ToLocalChecked();
811-
idx = 0;
812-
}
813-
}
814-
815-
if (idx > 0) {
816-
fn->Call(ctx, ary, idx, argv).ToLocalChecked();
804+
request_v.push_back(w->GetOwner());
817805
}
818806

819-
args.GetReturnValue().Set(ary);
807+
args.GetReturnValue().Set(
808+
Array::New(env->isolate(), request_v.data(), request_v.size()));
820809
}
821810

822-
823811
// Non-static, friend of HandleWrap. Could have been a HandleWrap method but
824812
// implemented here for consistency with GetActiveRequests().
825813
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {

0 commit comments

Comments
 (0)