Skip to content

Commit 2ed10f1

Browse files
committed
src: fix minor inefficiency in Buffer::New() call
Commit ccb199a ("src: fix deprecation warnings") passes env()->isolate() to the Buffer::New() call. It's somewhat inefficient because the callee looks up the environment from the isolate. Just pass the env directly. PR-URL: #1577 Reviewed-By: Trevor Norris <[email protected]>
1 parent f696c9e commit 2ed10f1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/spawn_sync.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ void SyncProcessStdioPipe::Close() {
165165
}
166166

167167

168-
Local<Object> SyncProcessStdioPipe::GetOutputAsBuffer(Isolate* isolate) const {
168+
Local<Object> SyncProcessStdioPipe::GetOutputAsBuffer(Environment* env) const {
169169
size_t length = OutputLength();
170-
Local<Object> js_buffer = Buffer::New(isolate, length);
170+
Local<Object> js_buffer = Buffer::New(env, length);
171171
CopyOutput(Buffer::Data(js_buffer));
172172
return js_buffer;
173173
}
@@ -679,7 +679,7 @@ Local<Array> SyncProcessRunner::BuildOutputArray() {
679679
for (uint32_t i = 0; i < stdio_count_; i++) {
680680
SyncProcessStdioPipe* h = stdio_pipes_[i];
681681
if (h != nullptr && h->writable())
682-
js_output->Set(i, h->GetOutputAsBuffer(env()->isolate()));
682+
js_output->Set(i, h->GetOutputAsBuffer(env()));
683683
else
684684
js_output->Set(i, Null(env()->isolate()));
685685
}

src/spawn_sync.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SyncProcessStdioPipe {
7272
int Start();
7373
void Close();
7474

75-
Local<Object> GetOutputAsBuffer(Isolate* isolate) const;
75+
Local<Object> GetOutputAsBuffer(Environment* env) const;
7676

7777
inline bool readable() const;
7878
inline bool writable() const;

0 commit comments

Comments
 (0)