-
-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Core] Optimize HashMap
#90082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Optimize HashMap
#90082
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ class StringName { | |
| bool operator!=(const char *p_name) const; | ||
|
|
||
| int idx = 0; | ||
| uint32_t hash_mixed = 0; | ||
| uint32_t hash = 0; | ||
| _Data *prev = nullptr; | ||
| _Data *next = nullptr; | ||
|
|
@@ -145,6 +146,16 @@ class StringName { | |
| return get_empty_hash(); | ||
| } | ||
| } | ||
|
|
||
| // Used by HashMapHasherDefault. Don`t use it as seed to create other hash. | ||
| _FORCE_INLINE_ uint32_t hash_mixed() const { | ||
| if (unlikely(_data == nullptr)) { | ||
| return get_empty_hash(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this not have to be mixed? It should return a plain |
||
| } | ||
|
|
||
| return _data->hash_mixed; | ||
| } | ||
|
|
||
| _FORCE_INLINE_ const void *data_unique_pointer() const { | ||
| return (void *)_data; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,3 +41,12 @@ bool _hashmap_variant_less_than(const Variant &p_left, const Variant &p_right) { | |
| } | ||
| return res; | ||
| } | ||
|
|
||
| // Explicit instantiation. | ||
| template class HashMap<int, int>; | ||
| template class HashMap<String, int>; | ||
| template class HashMap<StringName, bool>; | ||
| template class HashMap<StringName, StringName>; | ||
| template class HashMap<StringName, String>; | ||
| template class HashMap<StringName, Variant>; | ||
| template class HashMap<StringName, int>; | ||
|
Comment on lines
+45
to
+52
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe explicit |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.