aboutsummaryrefslogtreecommitdiff
path: root/src/ptr_set.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-05 01:25:37 +0000
committergingerBill <bill@gingerbill.org>2023-01-05 01:25:37 +0000
commitbbb2164e38e3930cb79c5e7bc61b421e38131361 (patch)
tree5abcf64a674ed5e0d553fb8e621d0493088e7e93 /src/ptr_set.cpp
parentbe23d83fc8a940de98d372276d475372e61b4bf2 (diff)
Inline map gets; cast explicitly on TOMBSTONE checking
Diffstat (limited to 'src/ptr_set.cpp')
-rw-r--r--src/ptr_set.cpp10
1 files changed, 5 insertions, 5 deletions
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<T *> {
template <typename T>
struct PtrSet {
static_assert(TypeIsPointer<T>::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<T> *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<T>::TOMBSTONE || *key == nullptr) {
+ if (*key == (T)PtrSet<T>::TOMBSTONE || *key == nullptr) {
*key = ptr;
s->count++;
return false;
@@ -157,7 +157,7 @@ gb_internal void ptr_set_remove(PtrSet<T> *s, T ptr) {
isize index = ptr_set__find(s, ptr);
if (index >= 0) {
GB_ASSERT(s->count > 0);
- s->keys[index] = PtrSet<T>::TOMBSTONE;
+ s->keys[index] = (T)PtrSet<T>::TOMBSTONE;
s->count--;
}
}
@@ -180,7 +180,7 @@ struct PtrSetIterator {
return *this;
}
T key = set->keys[index];
- if (key != nullptr && key != PtrSet<T>::TOMBSTONE) {
+ if (key != nullptr && key != (T)PtrSet<T>::TOMBSTONE) {
return *this;
}
}
@@ -202,7 +202,7 @@ gb_internal PtrSetIterator<T> begin(PtrSet<T> &set) noexcept {
usize index = 0;
while (index < set.capacity) {
T key = set.keys[index];
- if (key != nullptr && key != PtrSet<T>::TOMBSTONE) {
+ if (key != nullptr && key != (T)PtrSet<T>::TOMBSTONE) {
break;
}
index++;