@@ -1608,27 +1608,21 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
1608
1608
Local<Array> ary = Array::New (args.GetIsolate ());
1609
1609
Local<Context> ctx = env->context ();
1610
1610
Local<Function> fn = env->push_values_to_array_function ();
1611
- static const size_t argc = 8 ;
1612
- Local<Value> argv[argc];
1613
- size_t i = 0 ;
1611
+ Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX];
1612
+ size_t idx = 0 ;
1614
1613
1615
1614
for (auto w : *env->req_wrap_queue ()) {
1616
- if (w->persistent ().IsEmpty () == false ) {
1617
- argv[i++ % argc] = w->object ();
1618
- if ((i % argc) == 0 ) {
1619
- HandleScope scope (env->isolate ());
1620
- fn->Call (ctx, ary, argc, argv).ToLocalChecked ();
1621
- for (auto && arg : argv) {
1622
- arg = Local<Value>();
1623
- }
1624
- }
1615
+ if (w->persistent ().IsEmpty ())
1616
+ continue ;
1617
+ argv[idx] = w->object ();
1618
+ if (++idx >= ARRAY_SIZE (argv)) {
1619
+ fn->Call (ctx, ary, idx, argv).ToLocalChecked ();
1620
+ idx = 0 ;
1625
1621
}
1626
1622
}
1627
1623
1628
- const size_t remainder = i % argc;
1629
- if (remainder > 0 ) {
1630
- HandleScope scope (env->isolate ());
1631
- fn->Call (ctx, ary, remainder , argv).ToLocalChecked ();
1624
+ if (idx > 0 ) {
1625
+ fn->Call (ctx, ary, idx, argv).ToLocalChecked ();
1632
1626
}
1633
1627
1634
1628
args.GetReturnValue ().Set (ary);
@@ -1641,7 +1635,10 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
1641
1635
Environment* env = Environment::GetCurrent (args);
1642
1636
1643
1637
Local<Array> ary = Array::New (env->isolate ());
1644
- int i = 0 ;
1638
+ Local<Context> ctx = env->context ();
1639
+ Local<Function> fn = env->push_values_to_array_function ();
1640
+ Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX];
1641
+ size_t idx = 0 ;
1645
1642
1646
1643
Local<String> owner_sym = env->owner_string ();
1647
1644
@@ -1652,7 +1649,14 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
1652
1649
Local<Value> owner = object->Get (owner_sym);
1653
1650
if (owner->IsUndefined ())
1654
1651
owner = object;
1655
- ary->Set (i++, owner);
1652
+ argv[idx] = owner;
1653
+ if (++idx >= ARRAY_SIZE (argv)) {
1654
+ fn->Call (ctx, ary, idx, argv).ToLocalChecked ();
1655
+ idx = 0 ;
1656
+ }
1657
+ }
1658
+ if (idx > 0 ) {
1659
+ fn->Call (ctx, ary, idx, argv).ToLocalChecked ();
1656
1660
}
1657
1661
1658
1662
args.GetReturnValue ().Set (ary);
0 commit comments