From 60c49c31beb46ced55e7be56852b0d993d93dacd Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 6 Apr 2023 01:14:55 +0200 Subject: [PATCH] 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. --- src/node_realm-inl.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node_realm-inl.h b/src/node_realm-inl.h index 6a6e2a0c51d307..c6a85d24d1767c 100644 --- a/src/node_realm-inl.h +++ b/src/node_realm-inl.h @@ -88,14 +88,14 @@ inline T* Realm::AddBindingData(v8::Local context, // This won't compile if T is not a BaseObject subclass. BaseObjectPtr item = MakeDetachedBaseObject(this, target, std::forward(args)...); - BindingDataStore* map = - static_cast(context->GetAlignedPointerFromEmbedderData( - ContextEmbedderIndex::kBindingDataStoreIndex)); - DCHECK_NOT_NULL(map); + DCHECK_EQ(context->GetAlignedPointerFromEmbedderData( + ContextEmbedderIndex::kBindingDataStoreIndex), + &binding_data_store_); constexpr size_t binding_index = static_cast(T::binding_type_int); static_assert(binding_index < std::tuple_size_v); - CHECK(!(*map)[binding_index]); // Should not insert the binding twice. - (*map)[binding_index] = item; + // Should not insert the binding twice. + CHECK(!binding_data_store_[binding_index]); + binding_data_store_[binding_index] = item; DCHECK_EQ(GetBindingData(context), item.get()); return item.get(); }