diff --git a/src/builtins/search.c b/src/builtins/search.c index 72ce9875..c11d6e20 100644 --- a/src/builtins/search.c +++ b/src/builtins/search.c @@ -3,6 +3,28 @@ #include "../utils/mut.h" #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 && n20 && we<=el_i16 && xe<=el_i16 && we!=el_bit && xe!=el_bit) { + TABLE(w, x, i32, wia, i) + return r; + } i32* rp; B r = m_i32arrc(&rp, x); H_b2i* map = m_b2i(64); SGetU(x) @@ -102,25 +128,7 @@ 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) { - usz xt = 1<<(8*elWidth(xe)); // Range of x writes - usz wt = 1<<(8*elWidth(we)); // Range of w lookups - usz t = xt>wt? xt : wt; // Table allocation width - void* wp = tyany_ptr(w); - void* xp = tyany_ptr(x); - usz m=wia, n=xia; - i8* rp; B r = m_i8arrv(&rp, m); - TALLOC(u8, tab0, t); u8* tab = tab0 + t/2; - // Initialize - if (we==el_i16 && m