summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-10-10 09:29:46 +0200
committerlemon <lsof@mailbox.org>2022-10-10 09:29:46 +0200
commitcfb9a64a40016f71370433f9220b9d3ce0d735d8 (patch)
tree9226c594cbfcca05c05411f50b30c32288f37518
parenteeb528e62e47d1b3a76be949eccc24550cfc96d0 (diff)
better delstring()
-rw-r--r--pez.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pez.c b/pez.c
index 2059387..34a0e76 100644
--- a/pez.c
+++ b/pez.c
@@ -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;
}