Fix hashmap put all for create + test case

Closes: #1695
This commit is contained in:
Tomas Kallup
2024-12-17 23:54:35 +01:00
committed by Christoffer Lerno
parent 42c9c9894b
commit ca88afbf5b
4 changed files with 40 additions and 7 deletions

View File

@@ -470,8 +470,11 @@ fn void HashMap.put_all_for_create(&map, HashMap* other_map) @private
if (!other_map.count) return;
foreach (Entry *e : other_map.table)
{
if (!e) continue;
map.put_for_create(e.key, e.value);
while (e)
{
map.put_for_create(e.key, e.value);
e = e.next;
}
}
}

View File

@@ -131,8 +131,11 @@ fn Map new_from_map(Map other_map, Allocator allocator = null)
if (!other_map_impl.count) return (Map)map;
foreach (Entry *e : other_map_impl.table)
{
if (!e) continue;
map._put_for_create(e.key, e.value);
while (e)
{
map._put_for_create(e.key, e.value);
e = e.next;
}
}
return (Map)map;
}