summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-11-09 11:38:56 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-11-14 02:59:44 +0800
commit8c60d931f2046c1a552bed1e0d5d84f731204770 (patch)
tree457708d553da9ae9b25afdd327fde8486c50a48f /src
parent235afb4c6ad79fbf44c2a2d8e1aa8b85b5ac39f7 (diff)
downloadandroid-node-v8-8c60d931f2046c1a552bed1e0d5d84f731204770.tar.gz
android-node-v8-8c60d931f2046c1a552bed1e0d5d84f731204770.tar.bz2
android-node-v8-8c60d931f2046c1a552bed1e0d5d84f731204770.zip
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: https://github.com/nodejs/node/pull/24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_process.cc20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/node_process.cc b/src/node_process.cc
index 6e9c06e02d..161833ebbd 100644
--- a/src/node_process.cc
+++ b/src/node_process.cc
@@ -813,26 +813,14 @@ void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- Local<Array> ary = Array::New(env->isolate());
- Local<Context> ctx = env->context();
- Local<Function> fn = env->push_values_to_array_function();
- Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX];
- size_t idx = 0;
-
+ std::vector<Local<Value>> handle_v;
for (auto w : *env->handle_wrap_queue()) {
if (!HandleWrap::HasRef(w))
continue;
- argv[idx] = w->GetOwner();
- if (++idx >= arraysize(argv)) {
- fn->Call(ctx, ary, idx, argv).ToLocalChecked();
- idx = 0;
- }
- }
- if (idx > 0) {
- fn->Call(ctx, ary, idx, argv).ToLocalChecked();
+ handle_v.push_back(w->GetOwner());
}
-
- args.GetReturnValue().Set(ary);
+ args.GetReturnValue().Set(
+ Array::New(env->isolate(), handle_v.data(), handle_v.size()));
}
void DebugPortGetter(Local<Name> property,