Fast number-character (no matches) searches
This commit is contained in:
parent
0fb845d336
commit
0391cf4ca3
@ -191,7 +191,10 @@ static NOINLINE usz indexOfOne(B l, B e) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#define CHR_TO_INT if (elChr(we) && elChr(xe)) { \
|
||||
#define CHECK_CHRS_ELSE \
|
||||
if (!elNum(we)) { \
|
||||
if (elChr(we)) { \
|
||||
if (elNum(xe)) goto none_found; \
|
||||
if (we!=xe && we<=el_c16 && xe<=el_c16) { /* LUT uses signed integers, so needs equal-width args if we're gonna give unsigned ones */ \
|
||||
if (we>xe) x=taga(cpyC16Arr(x)); \
|
||||
else w=taga(cpyC16Arr(w)); \
|
||||
@ -199,7 +202,10 @@ static NOINLINE usz indexOfOne(B l, B e) {
|
||||
goto tyEls; \
|
||||
} \
|
||||
we-=el_c8-el_i8; xe-=el_c8-el_i8; goto tyEls; \
|
||||
}
|
||||
} \
|
||||
} else if (!elNum(xe)) { \
|
||||
if (elChr(xe)) goto none_found; \
|
||||
} else
|
||||
|
||||
B indexOf_c2(B t, B w, B x) {
|
||||
if (RARE(!isArr(w) || RNK(w)!=1)) {
|
||||
@ -218,10 +224,11 @@ B indexOf_c2(B t, B w, B x) {
|
||||
u8 we = TI(w,elType); usz wia = IA(w);
|
||||
u8 xe = TI(x,elType); usz xia = IA(x);
|
||||
if (wia==0 || xia==0) {
|
||||
decG(w); return i64EachDec(0, x);
|
||||
none_found:
|
||||
decG(w); return i64EachDec(wia, x);
|
||||
}
|
||||
|
||||
if (elNum(we) && elNum(xe)) { tyEls:
|
||||
CHECK_CHRS_ELSE { tyEls: // Both numbers
|
||||
if (we==el_bit) {
|
||||
u64* wp = bitarr_ptr(w);
|
||||
u64 w0 = 1 & wp[0];
|
||||
@ -257,7 +264,7 @@ B indexOf_c2(B t, B w, B x) {
|
||||
TABLE(w, x, i32, wia, i)
|
||||
return reduceI32Width(r, wia);
|
||||
}
|
||||
} else { CHR_TO_INT; }
|
||||
}
|
||||
|
||||
i32* rp; B r = m_i32arrc(&rp, x);
|
||||
H_b2i* map = m_b2i(64);
|
||||
@ -302,10 +309,11 @@ B memberOf_c2(B t, B w, B x) {
|
||||
u8 we = TI(w,elType); usz wia = IA(w);
|
||||
u8 xe = TI(x,elType); usz xia = IA(x);
|
||||
if (wia==0 || xia==0) {
|
||||
none_found:
|
||||
decG(x); return i64EachDec(0, w);
|
||||
}
|
||||
|
||||
if (elNum(we) && elNum(xe)) { tyEls:
|
||||
CHECK_CHRS_ELSE { tyEls: // Both numbers
|
||||
#define WEQ(V) C2(eq, incG(w), V)
|
||||
if (xe==el_bit) {
|
||||
u64* xp = bitarr_ptr(x);
|
||||
@ -337,7 +345,7 @@ B memberOf_c2(B t, B w, B x) {
|
||||
TABLE(x, w, i8, 0, 1)
|
||||
return taga(cpyBitArr(r));
|
||||
}
|
||||
} else { CHR_TO_INT; }
|
||||
}
|
||||
|
||||
H_Sb* set = m_Sb(64);
|
||||
SGetU(x) SGetU(w)
|
||||
@ -353,7 +361,7 @@ B memberOf_c2(B t, B w, B x) {
|
||||
decG(x);
|
||||
return r;
|
||||
}
|
||||
#undef CHR_TO_INT
|
||||
#undef CHECK_CHRS_ELSE
|
||||
|
||||
B count_c2(B t, B w, B x) {
|
||||
if (RARE(!isArr(w) || RNK(w)!=1)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user