Skip to content

Commit fe4be58

Browse files
committed
fs: cache context lookup in vectored io loops
1 parent 1409ac4 commit fe4be58

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/node_file.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,9 +2391,10 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
23912391

23922392
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());
23932393

2394+
Local<Context> context = env->context();
23942395
for (uint32_t i = 0; i < iovs.length(); i++) {
23952396
Local<Value> chunk;
2396-
if (!chunks->Get(env->context(), i).ToLocal(&chunk)) return;
2397+
if (!chunks->Get(context, i).ToLocal(&chunk)) return;
23972398
CHECK(Buffer::HasInstance(chunk));
23982399
iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk));
23992400
}
@@ -2776,9 +2777,10 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
27762777
MaybeStackBuffer<uv_buf_t> iovs(buffers->Length());
27772778

27782779
// Init uv buffers from ArrayBufferViews
2780+
Local<Context> context = env->context();
27792781
for (uint32_t i = 0; i < iovs.length(); i++) {
27802782
Local<Value> buffer;
2781-
if (!buffers->Get(env->context(), i).ToLocal(&buffer)) return;
2783+
if (!buffers->Get(context, i).ToLocal(&buffer)) return;
27822784
CHECK(Buffer::HasInstance(buffer));
27832785
iovs[i] = uv_buf_init(Buffer::Data(buffer), Buffer::Length(buffer));
27842786
}

0 commit comments

Comments
 (0)