From 1fb011f56cdcf85e9fd540270de3e5b45a9170b6 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 31 Dec 2024 02:38:22 -0500 Subject: [PATCH] hmap_chained: fix for not properly being able to override slots with matching key (that were still occupied) --- code/grime/hashmap_chained.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/grime/hashmap_chained.odin b/code/grime/hashmap_chained.odin index 52006c4..5e6d2a5 100644 --- a/code/grime/hashmap_chained.odin +++ b/code/grime/hashmap_chained.odin @@ -223,7 +223,7 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) - return & surface_slot.value, error } - if ! surface_slot.occupied + if ! surface_slot.occupied || surface_slot.key == key { surface_slot.key = key surface_slot.value = value @@ -257,7 +257,7 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) - } } - if ! slot.next.occupied + if ! slot.next.occupied || surface_slot.key == key { slot.next.key = key slot.next.value = value