Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-02-13 22:40:50 +0300
committerAnna Henningsen <anna@addaleax.net>2020-02-15 23:39:32 +0300
commita7c523e26df468782691c7e16b2e033c6256beb3 (patch)
tree33e01d937892b62c7b424ca4623b215b417d5567 /src/spawn_sync.cc
parent79296dc2d02c0b9872bbfcbb89148ea036a546d0 (diff)
src: prefer 3-argument Array::New()
This is nicer, because: 1. It reduces overall code size, 2. It’s faster, because `Object::Set()` calls are relatively slow, and 3. It helps avoid invalid `.Check()`/`.FromJust()` calls. PR-URL: https://github.com/nodejs/node/pull/31775 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/spawn_sync.cc')
-rw-r--r--src/spawn_sync.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc
index 3b277ad70ad..589b77f6c1e 100644
--- a/src/spawn_sync.cc
+++ b/src/spawn_sync.cc
@@ -721,18 +721,18 @@ Local<Array> SyncProcessRunner::BuildOutputArray() {
CHECK(!stdio_pipes_.empty());
EscapableHandleScope scope(env()->isolate());
- Local<Context> context = env()->context();
- Local<Array> js_output = Array::New(env()->isolate(), stdio_count_);
+ MaybeStackBuffer<Local<Value>, 8> js_output(stdio_pipes_.size());
for (uint32_t i = 0; i < stdio_pipes_.size(); i++) {
SyncProcessStdioPipe* h = stdio_pipes_[i].get();
if (h != nullptr && h->writable())
- js_output->Set(context, i, h->GetOutputAsBuffer(env())).Check();
+ js_output[i] = h->GetOutputAsBuffer(env());
else
- js_output->Set(context, i, Null(env()->isolate())).Check();
+ js_output[i] = Null(env()->isolate());
}
- return scope.Escape(js_output);
+ return scope.Escape(
+ Array::New(env()->isolate(), js_output.out(), js_output.length()));
}
Maybe<int> SyncProcessRunner::ParseOptions(Local<Value> js_value) {