Shortcut for hash-table dyadic ⊒

This commit is contained in:
Marshall Lochbaum 2023-11-07 09:59:53 -05:00
parent 4bf4149d40
commit a4290b1f5c

View File

@ -458,6 +458,7 @@ fn hashtab{T, name}(rp:*rty{name}, ip:*T, m:usz, fp:*T, n:usz, links:ity{name})
def prog_lookup{swap} = { # Progressive Index-of lookup
def rev{a,b} = if (swap) tup{b,a} else tup{a,b}
memset{*u32~~rp, ...rev{m,n}}
c:usz = m; def shortcut = makelabel{}
@for (fp over i to n) {
h := hash_val{fp}; j := h>>sh
k := load{hash,j}
@ -467,6 +468,7 @@ fn hashtab{T, name}(rp:*rty{name}, ip:*T, m:usz, fp:*T, n:usz, links:ity{name})
def {inds} = vals; def {link} = links
ti := load{inds, j}
store{rp, ...rev{i, m-ti}}
c -= promote{usz,ti>0}; if (c==0) goto{shortcut}
ti = load{link, ti}
if (ti > 0) {
store{inds, j, ti}
@ -482,6 +484,7 @@ fn hashtab{T, name}(rp:*rty{name}, ip:*T, m:usz, fp:*T, n:usz, links:ity{name})
}
}
}
setlabel{shortcut}
}
if (prim=='⊒') {
if (not swap) prog_lookup{0} else prog_lookup{1}