Skip to content

Commit 77c67fd

Browse files
committed
update context usage in WriteBuffers and ReadBuffers functions
1 parent fe4be58 commit 77c67fd

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/node_file.cc

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

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

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

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

src/node_realm-inl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "node_context_data.h"
77
#include "node_realm.h"
8+
#include "util-inl.h"
89

910
namespace node {
1011

@@ -46,6 +47,10 @@ inline v8::Isolate* Realm::isolate() const {
4647
return isolate_;
4748
}
4849

50+
inline v8::Local<v8::Context> Realm::context() const {
51+
return PersistentToLocal::Strong(context_);
52+
}
53+
4954
inline Realm::Kind Realm::kind() const {
5055
return kind_;
5156
}

src/node_realm.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,6 @@ void Realm::VerifyNoStrongBaseObjects() {
295295
});
296296
}
297297

298-
v8::Local<v8::Context> Realm::context() const {
299-
return PersistentToLocal::Strong(context_);
300-
}
301-
302298
// Per-realm strong value accessors. The per-realm values should avoid being
303299
// accessed across realms.
304300
#define V(PropertyName, TypeName) \

0 commit comments

Comments
 (0)