fix shared •HashMap value list

This commit is contained in:
dzaima 2024-06-30 14:06:05 +03:00
parent 9c05b68870
commit 2ce983041c
2 changed files with 3 additions and 1 deletions

View File

@ -738,7 +738,7 @@ void hashmap_set(B* vars, B w, B x) {
B* keys = harr_ptr(vars[0]);
HASHMAP_INSERT(
w,
B* s = harr_ptr(vars[1])+i; dec(*s); dec(w); *s=x; return;
B vs = vars[1]; if (!reusable(vs)) vars[1] = vs = taga(cpyHArr(vs)); B* s = harr_ptr(vs)+i; dec(*s); dec(w); *s=x; return;
)
map->pop++;
if (map->pop>>(64-3-sh)>7 || je==map->sz-1) { // keep load <= 7/8

View File

@ -59,3 +59,5 @@ a←(•ParseFloat¨ "1.2"‿"-0"‿"0")∾-⊸⋈0÷0 ⋄ ! (0‿3‿3‿3⊏a)
!"•HashMap: 𝕨 contained duplicate keys" % "strs" •HashMap "stri"
!"(hashmap).Get: key not found" % ("abc""de""fgh" •HashMap ¨3).Get "fg"
!"(hashmap).Delete: key not found" % ("abc""de""fgh" •HashMap ¨3).Delete 'a'
m 12 •HashMap v•internal.Unshare 'a'4 1 m.Set 9 v, m.Keys@, m.Values@ %% 'a'4, 12, 94
m 12 •HashMap •internal.Unshare 'a'4 vm.Values@ 1 m.Set 9 v, m.Keys@, m.Values@ %% 'a'4, 12, 94