From 96740566e997a288c8ede127e866d01a2b47559d Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 21 Oct 2022 20:11:40 -0400 Subject: [PATCH] Extend lookup code to boolean searched-for array --- src/builtins/search.c | 51 ++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/builtins/search.c b/src/builtins/search.c index c11d6e20..b9c8b8c7 100644 --- a/src/builtins/search.c +++ b/src/builtins/search.c @@ -4,26 +4,31 @@ #include "../utils/talloc.h" #define TABLE(IN, FOR, TY, INIT, SET) \ - usz it = 1<<(8*elWidth(IN##e)); /* Range of writes */ \ - usz ft = 1<<(8*elWidth(FOR##e)); /* Range of lookups */ \ - usz t = it>ft? it : ft; /* Table allocation width */ \ - TY* rp; B r = m_##TY##arrc(&rp, FOR); \ - TALLOC(TY, tab0, t); TY* tab = tab0 + t/2; \ - usz m=IN##ia, n=FOR##ia; \ - void* ip = tyany_ptr(IN); \ - void* fp = tyany_ptr(FOR); \ - /* Initialize */ \ - if (FOR##e==el_i16 && nft? it : ft; /* Table allocation width */ \ + TALLOC(TY, tab0, t); TY* tab = tab0 + t/2; \ + usz m=IN##ia, n=FOR##ia; \ + void* ip = tyany_ptr(IN); \ + void* fp = tyany_ptr(FOR); \ + /* Initialize */ \ + if (FOR##e==el_i16 && n20 && we<=el_i16 && xe<=el_i16 && we!=el_bit && xe!=el_bit) { + if (xia+wia>20 && we<=el_i16 && xe<=el_i16 && we!=el_bit) { + B r; TABLE(w, x, i32, wia, i) return r; } @@ -127,7 +133,8 @@ B memberOf_c2(B t, B w, B x) { } #undef WEQ // TODO O(wia×xia) for small wia - if (xia+wia>20 && we<=el_i16 && xe<=el_i16 && we!=el_bit) { + if (xia+wia>20 && we<=el_i16 && xe<=el_i16) { + B r; TABLE(x, w, i8, 0, 1) return num_squeeze(r); }