mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix delete_key #262
This commit is contained in:
+11
-6
@@ -724,7 +724,7 @@ __get_map_key :: proc "contextless" (key: $K) -> Map_Key {
|
|||||||
}
|
}
|
||||||
case Type_Info_String:
|
case Type_Info_String:
|
||||||
str := (^string)(&key)^;
|
str := (^string)(&key)^;
|
||||||
map_key.hash = __default_hash_string(str);
|
map_key.hash = default_hash_string(str);
|
||||||
map_key.str = str;
|
map_key.str = str;
|
||||||
case:
|
case:
|
||||||
panic("Unhandled map key type");
|
panic("Unhandled map key type");
|
||||||
@@ -924,15 +924,20 @@ __dynamic_map_erase :: proc(using h: Map_Header, fr: Map_Find_Result) #no_bounds
|
|||||||
prev.next = curr.next;
|
prev.next = curr.next;
|
||||||
}
|
}
|
||||||
if (fr.entry_index == m.entries.len-1) {
|
if (fr.entry_index == m.entries.len-1) {
|
||||||
m.entries.len -= 1;
|
// NOTE(bill): No need to do anything else, just pop
|
||||||
return;
|
} else {
|
||||||
}
|
old := __dynamic_map_get_entry(h, fr.entry_index);
|
||||||
|
end := __dynamic_map_get_entry(h, m.entries.len-1);
|
||||||
|
mem.copy(old, end, entry_size);
|
||||||
|
|
||||||
last := __dynamic_map_find(h, __dynamic_map_get_entry(h, fr.entry_index).key);
|
if last := __dynamic_map_find(h, old.key); last.entry_prev >= 0 {
|
||||||
if last.entry_prev >= 0 {
|
|
||||||
last_entry := __dynamic_map_get_entry(h, last.entry_prev);
|
last_entry := __dynamic_map_get_entry(h, last.entry_prev);
|
||||||
last_entry.next = fr.entry_index;
|
last_entry.next = fr.entry_index;
|
||||||
} else {
|
} else {
|
||||||
m.hashes[last.hash_index] = fr.entry_index;
|
m.hashes[last.hash_index] = fr.entry_index;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(bill): Is this correct behaviour?
|
||||||
|
m.entries.len -= 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user