From cfb9a64a40016f71370433f9220b9d3ce0d735d8 Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 10 Oct 2022 09:29:46 +0200 Subject: better delstring() --- pez.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'pez.c') 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; } -- cgit v1.2.3