even more microoptimization
This commit is contained in:
parent
c794fb0ef9
commit
f27ba6d569
@ -12,20 +12,25 @@
|
|||||||
NOINLINE B num_squeezeF(B x, usz ia) {
|
NOINLINE B num_squeezeF(B x, usz ia) {
|
||||||
u32 or = 0;
|
u32 or = 0;
|
||||||
SGetU(x)
|
SGetU(x)
|
||||||
|
Arr* a;
|
||||||
for (usz i = 0; i < ia; i++) {
|
for (usz i = 0; i < ia; i++) {
|
||||||
B cr = GetU(x,i);
|
B cr = GetU(x,i);
|
||||||
if (RARE(!q_i32(cr))) {
|
if (RARE(!q_i32(cr))) {
|
||||||
while (i<ia) if (!isF64(GetU(x,i++))) return x;
|
while (i<ia) if (!isF64(GetU(x,i++))) return FL_SET(x, fl_squoze);
|
||||||
return taga(cpyF64Arr(x));
|
a = (Arr*) cpyF64Arr(x);
|
||||||
|
goto retn;
|
||||||
}
|
}
|
||||||
i32 c = o2iu(cr);
|
i32 c = o2iu(cr);
|
||||||
or|= ((u32)c & ~1) ^ (u32)(c>>31);
|
or|= ((u32)c & ~1) ^ (u32)(c>>31);
|
||||||
}
|
}
|
||||||
|
a = or==0? (Arr*)cpyBitArr(x)
|
||||||
|
: or<=(u32)I8_MAX? (Arr*)cpyI8Arr (x)
|
||||||
|
: or<=(u32)I16_MAX? (Arr*)cpyI16Arr(x)
|
||||||
|
: (Arr*)cpyI32Arr(x);
|
||||||
|
|
||||||
if (or==0) return taga(cpyBitArr(x));
|
retn:
|
||||||
else if (or<=(u32)I8_MAX ) return taga(cpyI8Arr (x));
|
FLV_SET(a, fl_squoze);
|
||||||
else if (or<=(u32)I16_MAX) return taga(cpyI16Arr(x));
|
return taga(a);
|
||||||
else return taga(cpyI32Arr(x));
|
|
||||||
}
|
}
|
||||||
B num_squeeze(B x) {
|
B num_squeeze(B x) {
|
||||||
usz ia = a(x)->ia;
|
usz ia = a(x)->ia;
|
||||||
@ -86,15 +91,20 @@ B num_squeeze(B x) {
|
|||||||
mostI8: if(or>0 ) goto r_i8;
|
mostI8: if(or>0 ) goto r_i8;
|
||||||
mostBit: goto r_bit;
|
mostBit: goto r_bit;
|
||||||
|
|
||||||
B res;
|
B rb; Arr* ra;
|
||||||
r_f: res = num_squeezeF(x,ia); goto retn;
|
r_f: return num_squeezeF(x, ia); // rb = num_squeezeF(x,ia); goto retn;
|
||||||
r_x: res = x; goto retn;
|
r_x: ra = a(x); rb = x; goto retn;
|
||||||
r_f64: res = taga(cpyF64Arr(x)); goto retn;
|
r_f64: ra = (Arr*)cpyF64Arr(x); goto tag;
|
||||||
r_i32: res = taga(cpyI32Arr(x)); goto retn;
|
r_i32: ra = (Arr*)cpyI32Arr(x); goto tag;
|
||||||
r_i16: res = taga(cpyI16Arr(x)); goto retn;
|
r_i16: ra = (Arr*)cpyI16Arr(x); goto tag;
|
||||||
r_i8: res = taga(cpyI8Arr (x)); goto retn;
|
r_i8: ra = (Arr*)cpyI8Arr (x); goto tag;
|
||||||
r_bit: res = taga(cpyBitArr(x)); goto retn;
|
r_bit: ra = (Arr*)cpyBitArr(x); goto tag;
|
||||||
retn: return FL_SET(res, fl_squoze);
|
|
||||||
|
tag:
|
||||||
|
rb = taga(ra);
|
||||||
|
retn:
|
||||||
|
FLV_SET(ra, fl_squoze);
|
||||||
|
return rb;
|
||||||
}
|
}
|
||||||
B chr_squeeze(B x) {
|
B chr_squeeze(B x) {
|
||||||
usz ia = a(x)->ia;
|
usz ia = a(x)->ia;
|
||||||
@ -151,7 +161,7 @@ B chr_squeeze(B x) {
|
|||||||
}
|
}
|
||||||
if (or<=U8_MAX ) r_c8: return FL_SET(toC8Any(x), fl_squoze);
|
if (or<=U8_MAX ) r_c8: return FL_SET(toC8Any(x), fl_squoze);
|
||||||
else if (or<=U16_MAX) r_c16: return FL_SET(toC16Any(x), fl_squoze);
|
else if (or<=U16_MAX) r_c16: return FL_SET(toC16Any(x), fl_squoze);
|
||||||
else goto r_c32; r_c32: return FL_SET(toC32Any(x), fl_squoze);
|
else { goto r_c32; } r_c32: return FL_SET(toC32Any(x), fl_squoze);
|
||||||
/*when known typed:*/ r_x: return FL_SET(x, fl_squoze);
|
/*when known typed:*/ r_x: return FL_SET(x, fl_squoze);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
src/h.h
3
src/h.h
@ -535,8 +535,11 @@ enum Flags {
|
|||||||
fl_dsc=4, // sorted descending (non-ascending)
|
fl_dsc=4, // sorted descending (non-ascending)
|
||||||
};
|
};
|
||||||
#define FL_SET(X,F) ({ B x_ = (X); v(x_)->flags|= (F); x_; })
|
#define FL_SET(X,F) ({ B x_ = (X); v(x_)->flags|= (F); x_; })
|
||||||
|
#define FLV_SET(X,F) ({ AUTO x_ = (X); x_->flags|= (F); x_; })
|
||||||
#define FL_KEEP(X,F) ({ B x_ = (X); v(x_)->flags&= (F); x_; })
|
#define FL_KEEP(X,F) ({ B x_ = (X); v(x_)->flags&= (F); x_; })
|
||||||
|
#define FLV_KEEP(X,F) ({ AUTO x_ = (X); x_->flags&= (F); x_; })
|
||||||
#define FL_HAS(X,F) ((v(X)->flags&(F)) != 0)
|
#define FL_HAS(X,F) ((v(X)->flags&(F)) != 0)
|
||||||
|
#define FLV_HAS(X,F) (((X)->flags&(F)) != 0)
|
||||||
|
|
||||||
// refcount stuff
|
// refcount stuff
|
||||||
static bool reusable(B x) { return v(x)->refc==1; }
|
static bool reusable(B x) { return v(x)->refc==1; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user