aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-04-26 13:25:08 +0100
committergingerBill <bill@gingerbill.org>2024-04-26 13:25:08 +0100
commita3e77dcc3bc4cf7d0548afa73d38914354761aa0 (patch)
tree5c71048f33e4c1a87c6cb68b8e3af510b5e01bfe /src
parent7305478261700fc95f6748ba3091978a3fe7b1f3 (diff)
Minor clean up
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp16
-rw-r--r--src/string_map.cpp7
-rw-r--r--src/string_set.cpp4
3 files changed, 17 insertions, 10 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index 116f275bc..f3e14eeba 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -4309,17 +4309,21 @@ gb_internal bool correct_single_type_alias(CheckerContext *c, Entity *e) {
gb_internal bool correct_type_alias_in_scope_backwards(CheckerContext *c, Scope *s) {
bool correction = false;
- u32 n = s->elements.count;
- for (u32 i = n-1; i < n; i--) {
- correction |= correct_single_type_alias(c, s->elements.entries[i].value);
+ for (u32 n = s->elements.count, i = n-1; i < n; i--) {
+ Entity *e = s->elements.entries[i].value;
+ if (e != nullptr) {
+ correction |= correct_single_type_alias(c, e);
+ }
}
return correction;
}
gb_internal bool correct_type_alias_in_scope_forwards(CheckerContext *c, Scope *s) {
bool correction = false;
- u32 n = s->elements.count;
- for (isize i = 0; i < n; i++) {
- correction |= correct_single_type_alias(c, s->elements.entries[i].value);
+ for (auto const &entry : s->elements) {
+ Entity *e = entry.value;
+ if (e != nullptr) {
+ correction |= correct_single_type_alias(c, entry.value);
+ }
}
return correction;
}
diff --git a/src/string_map.cpp b/src/string_map.cpp
index f8b86a950..894579a03 100644
--- a/src/string_map.cpp
+++ b/src/string_map.cpp
@@ -2,8 +2,8 @@ GB_STATIC_ASSERT(sizeof(MapIndex) == sizeof(u32));
struct StringHashKey {
- u32 hash;
String string;
+ u32 hash;
operator String() const noexcept {
return this->string;
@@ -329,11 +329,12 @@ gb_internal StringMapEntry<T> const *begin(StringMap<T> const &m) noexcept {
template <typename T>
-gb_internal StringMapEntry<T> *end(StringMap<T> &m) {
+gb_internal StringMapEntry<T> *end(StringMap<T> &m) noexcept {
return m.entries + m.count;
}
template <typename T>
gb_internal StringMapEntry<T> const *end(StringMap<T> const &m) noexcept {
return m.entries + m.count;
-} \ No newline at end of file
+}
+
diff --git a/src/string_set.cpp b/src/string_set.cpp
index fb4640c20..a37d8ba80 100644
--- a/src/string_set.cpp
+++ b/src/string_set.cpp
@@ -208,7 +208,9 @@ gb_internal void string_set__erase(StringSet *s, MapFindResult fr) {
}
auto *entry = &s->entries[fr.entry_index];
*entry = s->entries[s->entries.count-1];
- StringHashKey key = {entry->hash, entry->value};
+ StringHashKey key;
+ key.hash = entry->hash;
+ key.string = entry->value;
last = string_set__find(s, key);
if (last.entry_prev != MAP_SENTINEL) {
s->entries[last.entry_prev].next = fr.entry_index;