diff options
| author | 2022-10-10 09:29:46 +0200 | |
|---|---|---|
| committer | 2022-10-10 09:29:46 +0200 | |
| commit | cfb9a64a40016f71370433f9220b9d3ce0d735d8 (patch) | |
| tree | 9226c594cbfcca05c05411f50b30c32288f37518 | |
| parent | eeb528e62e47d1b3a76be949eccc24550cfc96d0 (diff) | |
better delstring()
| -rw-r--r-- | pez.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -716,9 +716,14 @@ delarray(PezContext *cx, Array *arr) static void delstring(PezContext *cx, Str *str) { - Str **slot = strpool_lookup(cx, str->dat, str->n); - assert(slot && *slot == str); - *slot = NULL; + uint N = cx->strpool.N; + for (uint i = fnv1a(FNV1A_INI, str->dat, str->n) & (N - 1);; i = (i + 1) & (N - 1)) { + Str **slot = &cx->strpool.dat[i]; + if (*slot == str) { + *slot = NULL; + break; + } + } ++cx->strpool.deleted; --cx->strpool.count; } |