From af81da50e4af934e31084874f0651779440103e7 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 4 Nov 2023 17:52:22 -0400 Subject: [PATCH] Don't need to initialize indices for hashed Index-of --- src/singeli/src/hashtab.singeli | 6 +++++- src/singeli/src/search.singeli | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/singeli/src/hashtab.singeli b/src/singeli/src/hashtab.singeli index f07e2a05..92c200b7 100644 --- a/src/singeli/src/hashtab.singeli +++ b/src/singeli/src/hashtab.singeli @@ -50,6 +50,7 @@ def hash_alloc{logsz, msz, ext, Ts, v0s} = { def pe{{..._, p}} = p+sze # Next unallocated space given pointers so far def pl{{...R, T}} = { def ps=pl{R}; tup{...ps, *T~~pe{ps}+szo} } ptrs := pl{Ts} + def memset{_, ('any'), _} = {} # Indicates initialization not needed each{memset{., ., sze}, ptrs, v0s} def hash_resize{cc, m} = { @@ -66,7 +67,10 @@ def hash_alloc{logsz, msz, ext, Ts, v0s} = { k0 := h>>sh; k := k0; while (hash->k!=h0) ++k cc += cast_i{usz, k-k0} hash <-{k} h - each{{p,v0} => { v := p->j; p <-{j} v0; p <-{k} v }, vals, v0r} + def move{p,v0} = { + v := p->j; if (not same{v0,'any'}) p <-{j} v0; p <-{k} v + } + each{move, vals, v0r} } } } diff --git a/src/singeli/src/search.singeli b/src/singeli/src/search.singeli index 3f127954..5689d391 100644 --- a/src/singeli/src/search.singeli +++ b/src/singeli/src/search.singeli @@ -360,7 +360,7 @@ fn hashtab{T, name}(rp:*rty{name}, ip:*T, m:usz, fp:*T, n:usz, links:ity{name}) maxh := T~~maxvalue{T} def aux = prim!='∊' def {tabs, sz, sh, hash_resize, hash_free} = hash_alloc{ - sl, msz, ext, tup{T, ...aux**u32}, tup{maxh, ...aux**0} + sl, msz, ext, tup{T, ...aux**u32}, tup{maxh, ...aux**(if (prim=='⊐') 'any' else 0)} } def {hash,...vals} = tabs