From bbb2164e38e3930cb79c5e7bc61b421e38131361 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 5 Jan 2023 01:25:37 +0000 Subject: Inline map gets; cast explicitly on TOMBSTONE checking --- src/ptr_set.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ptr_set.cpp') diff --git a/src/ptr_set.cpp b/src/ptr_set.cpp index 8be2b0524..019ede8a5 100644 --- a/src/ptr_set.cpp +++ b/src/ptr_set.cpp @@ -12,7 +12,7 @@ struct TypeIsPointer { template struct PtrSet { static_assert(TypeIsPointer::value, "PtrSet::T must be a pointer"); - static constexpr T TOMBSTONE = (T)(~uintptr(0)); + static constexpr uintptr TOMBSTONE = ~(uintptr)(0ull); T * keys; usize count; @@ -133,7 +133,7 @@ gb_internal bool ptr_set_update(PtrSet *s, T ptr) { // returns true if it pre for (usize i = 0; i < s->capacity; i++) { T *key = &s->keys[hash_index]; GB_ASSERT(*key != ptr); - if (*key == PtrSet::TOMBSTONE || *key == nullptr) { + if (*key == (T)PtrSet::TOMBSTONE || *key == nullptr) { *key = ptr; s->count++; return false; @@ -157,7 +157,7 @@ gb_internal void ptr_set_remove(PtrSet *s, T ptr) { isize index = ptr_set__find(s, ptr); if (index >= 0) { GB_ASSERT(s->count > 0); - s->keys[index] = PtrSet::TOMBSTONE; + s->keys[index] = (T)PtrSet::TOMBSTONE; s->count--; } } @@ -180,7 +180,7 @@ struct PtrSetIterator { return *this; } T key = set->keys[index]; - if (key != nullptr && key != PtrSet::TOMBSTONE) { + if (key != nullptr && key != (T)PtrSet::TOMBSTONE) { return *this; } } @@ -202,7 +202,7 @@ gb_internal PtrSetIterator begin(PtrSet &set) noexcept { usize index = 0; while (index < set.capacity) { T key = set.keys[index]; - if (key != nullptr && key != PtrSet::TOMBSTONE) { + if (key != nullptr && key != (T)PtrSet::TOMBSTONE) { break; } index++; -- cgit v1.2.3