From 2ed10f13492221da0e5d1795bb0c780308c08d48 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 1 May 2015 17:25:18 +0200 Subject: [PATCH] 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: https://github.com/iojs/io.js/pull/1577 Reviewed-By: Trevor Norris --- src/spawn_sync.cc | 6 +++--- src/spawn_sync.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 901a4a001df051..15e4fe8b103b0d 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -165,9 +165,9 @@ void SyncProcessStdioPipe::Close() { } -Local SyncProcessStdioPipe::GetOutputAsBuffer(Isolate* isolate) const { +Local SyncProcessStdioPipe::GetOutputAsBuffer(Environment* env) const { size_t length = OutputLength(); - Local js_buffer = Buffer::New(isolate, length); + Local js_buffer = Buffer::New(env, length); CopyOutput(Buffer::Data(js_buffer)); return js_buffer; } @@ -679,7 +679,7 @@ Local SyncProcessRunner::BuildOutputArray() { for (uint32_t i = 0; i < stdio_count_; i++) { SyncProcessStdioPipe* h = stdio_pipes_[i]; if (h != nullptr && h->writable()) - js_output->Set(i, h->GetOutputAsBuffer(env()->isolate())); + js_output->Set(i, h->GetOutputAsBuffer(env())); else js_output->Set(i, Null(env()->isolate())); } diff --git a/src/spawn_sync.h b/src/spawn_sync.h index 9a544fa0576402..3069df610ffb8a 100644 --- a/src/spawn_sync.h +++ b/src/spawn_sync.h @@ -72,7 +72,7 @@ class SyncProcessStdioPipe { int Start(); void Close(); - Local GetOutputAsBuffer(Isolate* isolate) const; + Local GetOutputAsBuffer(Environment* env) const; inline bool readable() const; inline bool writable() const;