From 16b385fc7b3883cc3ce5965e30e55abd903166c1 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 21 Jul 2023 21:04:25 +0200 Subject: [PATCH] libluna: Some fixes so that HashTable collisions work properly --- libluna/include/luna/HashTable.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libluna/include/luna/HashTable.h b/libluna/include/luna/HashTable.h index df97aa06..243be925 100644 --- a/libluna/include/luna/HashTable.h +++ b/libluna/include/luna/HashTable.h @@ -48,13 +48,14 @@ template class HashTable usize i = index; do { - auto& bucket = m_buckets[index]; + auto& bucket = m_buckets[i]; if (bucket.has_value()) { if (*bucket == value) return bucket.value_ptr(); i++; } - return nullptr; + else + return nullptr; } while (i != index); return nullptr; @@ -70,7 +71,7 @@ template class HashTable usize i = index; do { - auto& bucket = m_buckets[index]; + auto& bucket = m_buckets[i]; if (bucket.has_value()) { if (*bucket == value) @@ -82,7 +83,8 @@ template class HashTable } i++; } - return false; + else + return false; } while (i != index); return false;