rearrange arr_shCopyUnchecked to not read SH(o) twice
and, while making a change that requires rebuilding all of CBQN, also make more of the arr_* fns return their Arr* argument to prepare for using them inline
This commit is contained in:
parent
3b1b171828
commit
4884580037
@ -63,23 +63,26 @@ static usz* arr_shAlloc(Arr* x, ur r) { // sets rank, allocates & returns shape
|
|||||||
x->sh = &x->ia;
|
x->sh = &x->ia;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static void arr_shSetI(Arr* x, ur r, ShArr* sh) { // set rank and assign and increment shape if needed
|
static Arr* arr_shSetI(Arr* x, ur r, ShArr* sh) { // set rank and assign and increment shape if needed
|
||||||
SPRNK(x,r);
|
SPRNK(x,r);
|
||||||
if (r>1) { x->sh = ptr_inc(sh)->a; }
|
if (r>1) x->sh = ptr_inc(sh)->a;
|
||||||
else { x->sh = &x->ia; }
|
else x->sh = &x->ia;
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
static void arr_shSetU(Arr* x, ur r, ShArr* sh) { // set rank and assign shape
|
static Arr* arr_shSetU(Arr* x, ur r, ShArr* sh) { // set rank and assign shape
|
||||||
SPRNK(x,r);
|
SPRNK(x,r);
|
||||||
if (r>1) { x->sh = sh->a; }
|
if (r>1) x->sh = sh->a;
|
||||||
else { x->sh = &x->ia; }
|
else x->sh = &x->ia;
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
static Arr* arr_shCopyUnchecked(Arr* n, B o) {
|
static Arr* arr_shCopyUnchecked(Arr* n, B o) {
|
||||||
ur r = SPRNK(n,RNK(o));
|
ur r = SPRNK(n,RNK(o));
|
||||||
if (r<=1) {
|
if (r<=1) {
|
||||||
n->sh = &n->ia;
|
n->sh = &n->ia;
|
||||||
} else {
|
} else {
|
||||||
ptr_inc(shObj(o));
|
usz* sh = SH(o);
|
||||||
n->sh = SH(o);
|
ptr_inc(shObjS(sh));
|
||||||
|
n->sh = sh;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user