mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-14 10:35:48 +00:00
Replace Scope.elements to use a custom hash map ScopeMap
This hash map is robin hood based with a inline slot amount for small scopes
This commit is contained in:
@@ -123,10 +123,11 @@ gb_internal bool ptr_set_update(PtrSet<T> *s, T ptr) { // returns true if it pre
|
||||
usize hash_index = (cast(usize)hash) & mask;
|
||||
GB_ASSERT(hash_index < s->capacity);
|
||||
for (usize i = 0; i < s->capacity; i++) {
|
||||
T *key = &s->keys[hash_index];
|
||||
GB_ASSERT(*key != ptr);
|
||||
if (*key == (T)PtrSet<T>::TOMBSTONE || *key == 0) {
|
||||
*key = ptr;
|
||||
T *key_ptr = &s->keys[hash_index];
|
||||
T key = *key_ptr;
|
||||
GB_ASSERT(key != ptr);
|
||||
if (key == (T)PtrSet<T>::TOMBSTONE || key == 0) {
|
||||
*key_ptr = ptr;
|
||||
s->count++;
|
||||
return false;
|
||||
}
|
||||
@@ -161,10 +162,11 @@ gb_internal bool ptr_set_update_with_mutex(PtrSet<T> *s, T ptr, RWSpinLock *m) {
|
||||
usize hash_index = (cast(usize)hash) & mask;
|
||||
GB_ASSERT(hash_index < s->capacity);
|
||||
for (usize i = 0; i < s->capacity; i++) {
|
||||
T *key = &s->keys[hash_index];
|
||||
GB_ASSERT(*key != ptr);
|
||||
if (*key == (T)PtrSet<T>::TOMBSTONE || *key == 0) {
|
||||
*key = ptr;
|
||||
T *key_ptr = &s->keys[hash_index];
|
||||
T key = *key_ptr;
|
||||
GB_ASSERT(key != ptr);
|
||||
if (key == (T)PtrSet<T>::TOMBSTONE || key == 0) {
|
||||
*key_ptr = ptr;
|
||||
s->count++;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user