summaryrefslogtreecommitdiff
path: root/src/node_realm.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2023-02-12 00:44:48 +0100
committerJoyee Cheung <joyeec9h3@gmail.com>2023-02-22 19:03:03 +0100
commitf32aa19400e41305a0145e452f2beee459fd13f9 (patch)
tree864cd429889d00222aa4627d0d753af9834cda87 /src/node_realm.h
parent1aed454342bb13e3223dea80e7a685230c4b8dab (diff)
downloadnode-new-f32aa19400e41305a0145e452f2beee459fd13f9.tar.gz
src: use an array for faster binding data lookup
Locally the hashing of the binding names sometimes has significant presence in the profile of bindings, because there can be collisions, which makes the cost of adding a new binding data non-trivial, but it's wasteful to spend time on hashing them or dealing with collisions at all, since we can just use the EmbedderObjectType enum as the key, as the string names are not actually used beyond debugging purposes and can be easily matched with a macro. And since we can just use the enum as the key, we do not even need the map and can just use an array with the enum as indices for the lookup. PR-URL: https://github.com/nodejs/node/pull/46620 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'src/node_realm.h')
-rw-r--r--src/node_realm.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/node_realm.h b/src/node_realm.h
index cf37fe31bd..04129eec47 100644
--- a/src/node_realm.h
+++ b/src/node_realm.h
@@ -21,9 +21,9 @@ struct RealmSerializeInfo {
friend std::ostream& operator<<(std::ostream& o, const RealmSerializeInfo& i);
};
-using BindingDataStore = std::unordered_map<FastStringKey,
- BaseObjectPtr<BaseObject>,
- FastStringKey::Hash>;
+using BindingDataStore = std::array<BaseObjectPtr<BaseObject>,
+ static_cast<size_t>(
+ BindingDataType::kBindingDataTypeCount)>;
/**
* node::Realm is a container for a set of JavaScript objects and functions