Skip to content

Commit 377a2bd

Browse files
committed
src: get binding data store directly from the realm
We now store the binding data store in the realm and invoke `Realm::AddBindingData` to add the binding data, so there is no need to get a reference to the binding data store from the context now, we can just get the reference from the realm.
1 parent 812e236 commit 377a2bd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/node_realm-inl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ inline T* Realm::AddBindingData(v8::Local<v8::Context> context,
8686
DCHECK_EQ(GetCurrent(context), this);
8787
// This won't compile if T is not a BaseObject subclass.
8888
BaseObjectPtr<T> item = MakeDetachedBaseObject<T>(this, target);
89-
BindingDataStore* map =
90-
static_cast<BindingDataStore*>(context->GetAlignedPointerFromEmbedderData(
91-
ContextEmbedderIndex::kBindingDataStoreIndex));
92-
DCHECK_NOT_NULL(map);
89+
DCHECK_EQ(context->GetAlignedPointerFromEmbedderData(
90+
ContextEmbedderIndex::kBindingDataStoreIndex),
91+
&binding_data_store_);
9392
constexpr size_t binding_index = static_cast<size_t>(T::binding_type_int);
9493
static_assert(binding_index < std::tuple_size_v<BindingDataStore>);
95-
CHECK(!(*map)[binding_index]); // Should not insert the binding twice.
96-
(*map)[binding_index] = item;
94+
// Should not insert the binding twice.
95+
CHECK(!binding_data_store_[binding_index]);
96+
binding_data_store_[binding_index] = item;
9797
DCHECK_EQ(GetBindingData<T>(context), item.get());
9898
return item.get();
9999
}

0 commit comments

Comments
 (0)