use *arrv_ptr more

This commit is contained in:
dzaima 2024-08-15 17:34:52 +03:00
parent 597fe07838
commit 0467e1c894
4 changed files with 9 additions and 9 deletions

View File

@ -474,7 +474,7 @@ B select_replace(u32 chr, B w, B x, B rep, usz wia, usz cam, usz csz) { // consu
case el_bit: { ra = reuse? a(REUSE(x)) : cpyBitArr(x);
TyArr* na = toBitArr(rep); rep = taga(na);
u64* np = bitarrv_ptr(na);
u64* rp = (void*)((TyArr*)ra)->a;
u64* rp = bitarrv_ptr((TyArr*)ra);
if (csz==1) {
for (usz i = 0; i < wia; i++) {
READ_W(cw, i);
@ -517,7 +517,7 @@ B select_replace(u32 chr, B w, B x, B rep, usz wia, usz cam, usz csz) { // consu
#define IMPL(T) do { \
if (csz!=1) goto do_tycell; \
T* rp = (void*)((TyArr*)ra)->a; \
T* rp = tyarrv_ptr((TyArr*)ra); \
T* np = tyany_ptr(rep); \
for (usz i = 0; i < wia; i++) { \
READ_W(cw, i); \
@ -536,7 +536,7 @@ B select_replace(u32 chr, B w, B x, B rep, usz wia, usz cam, usz csz) { // consu
do_tycell:;
u8 cwidth = csz * elWidth(re);
u8* rp = (u8*) ((TyArr*)ra)->a;
u8* rp = (u8*) tyarrv_ptr((TyArr*)ra);
u8* np = tyany_ptr(rep);
EqFnObj eq = EQFN_GET(re,re);
for (usz i = 0; i < wia; i++) {

View File

@ -390,7 +390,7 @@ B rand_range_c2(B t, B w, B x) {
u64 aFilled = u64am<<3;
assert(aFilled >= aExact);
r = m_arr(offsetof(TyArr,a) + aFilled, t, am);
void* rp = ((TyArr*)r)->a;
void* rp = tyarrv_ptr((TyArr*)r);
if (max & (max-1)) { // not power of two
if (t==t_i32arr) PLAINLOOP for (usz i = 0; i < am; i++) ((i32*)rp)[i] = wy2u0k(wyrand(&seed), max);
else if (t==t_i16arr) PLAINLOOP for (usz i = 0; i < am; i++) ((i16*)rp)[i] = wy2u0k(wyrand(&seed), max);

View File

@ -1388,7 +1388,7 @@ void ffi_init(void) {
usz maxlen = o2s(Get(x,2));
decG(x);
assert(PIA(buf)==maxlen);
int res = read(fd, ((TyArr*)buf)->a, maxlen);
int res = read(fd, tyarrv_ptr((TyArr*)buf), maxlen);
return m_vec2(m_f64(res), taga(buf));
}
case 4: {
@ -1397,7 +1397,7 @@ void ffi_init(void) {
Arr* buf = cpyI8Arr(Get(x,1));
usz maxlen = o2s(Get(x,2));
decG(x);
int res = write(fd, ((TyArr*)buf)->a, maxlen);
int res = write(fd, tyarrv_ptr((TyArr*)buf), maxlen);
ptr_dec(buf);
return m_f64(res);
}
@ -1406,7 +1406,7 @@ void ffi_init(void) {
}
case 6: {
SGet(x)
Arr* buf = cpyI16Arr(Get(x,0)); i16* a = (i16*)((TyArr*)buf)->a;
Arr* buf = cpyI16Arr(Get(x,0)); i16* a = (i16*)tyarrv_ptr((TyArr*)buf);
int nfds = o2i(Get(x,1));
int timeout = o2s(Get(x,2));
decG(x);

View File

@ -15,7 +15,7 @@ FORCE_INLINE MadeArr mut_make_arr(usz ia, u8 type, u8 el) {
return (MadeArr){(Arr*)t.c, t.c->a};
}
Arr* a = m_arr(sz, type, ia);
return (MadeArr){a, ((TyArr*)a)->a};
return (MadeArr){a, tyarrv_ptr((TyArr*)a)};
}
FORCE_INLINE void mut_init(Mut* m, u8 el) {
@ -40,7 +40,7 @@ NOINLINE Mut make_mut_init(ux ia, u8 el) {
#endif
static void* arr_ptr(Arr* t, u8 el) {
return el==el_B? (void*)((HArr*)t)->a : (void*)((TyArr*)t)->a;
return el==el_B? (void*)((HArr*)t)->a : tyarrv_ptr((TyArr*)t);
}
INIT_GLOBAL u8 reuseElType[t_COUNT];