use shcpy for copying shapes
This commit is contained in:
parent
3fa0463241
commit
54645df2a9
@ -62,7 +62,7 @@ B ud_c1(B t, B x) {
|
||||
for (usz i = 0; i < ria; i++) rp[i] = m_f64(0); // don't break if allocation errors
|
||||
|
||||
usz* rsh = arr_shAlloc(r, xia);
|
||||
if (rsh) memcpy(rsh, sh, sizeof(usz)*xia);
|
||||
if (rsh) shcpy(rsh, sh, xia);
|
||||
|
||||
i32 pos[xia]; B* crp = rp;
|
||||
ud_rec(&crp, 0, xia, pos, sh);
|
||||
|
||||
@ -86,8 +86,8 @@ B tbl_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
r = HARR_O(r).b;
|
||||
}
|
||||
if (rsh) {
|
||||
memcpy(rsh , a(w)->sh, wr*sizeof(usz));
|
||||
memcpy(rsh+wr, a(x)->sh, xr*sizeof(usz));
|
||||
shcpy(rsh , a(w)->sh, wr);
|
||||
shcpy(rsh+wr, a(x)->sh, xr);
|
||||
}
|
||||
decG(w); decG(x);
|
||||
if (EACH_FILLS) return homFil2(f, r, wf, xf);
|
||||
@ -435,7 +435,7 @@ B cell_c1(Md1D* d, B x) { B f = d->f;
|
||||
mut_fill(fc, 0, xf, csz); dec(xf);
|
||||
Arr* ca = mut_fp(fc);
|
||||
usz* csh = arr_shAlloc(ca, cr);
|
||||
if (cr>1) memcpy(csh, a(x)->sh+1, cr*sizeof(usz));
|
||||
if (cr>1) shcpy(csh, a(x)->sh+1, cr);
|
||||
decG(x);
|
||||
|
||||
if (CATCH) return emptyHVec();
|
||||
@ -450,7 +450,7 @@ B cell_c1(Md1D* d, B x) { B f = d->f;
|
||||
usz* rsh = arr_shAlloc(r, rr);
|
||||
if (rr>1) {
|
||||
rsh[0] = 0;
|
||||
memcpy(rsh+1, a(rc)->sh, (rr-1)*sizeof(usz));
|
||||
shcpy(rsh+1, a(rc)->sh, rr-1);
|
||||
}
|
||||
dec(rc);
|
||||
return taga(r);
|
||||
|
||||
@ -247,7 +247,7 @@ B rank_c1(Md2D* d, B x) { B f = d->f; B g = d->g;
|
||||
ShArr* csh;
|
||||
if (cr>1) {
|
||||
csh = m_shArr(cr);
|
||||
memcpy(csh->a, xsh+k, cr*sizeof(usz));
|
||||
shcpy(csh->a, xsh+k, cr);
|
||||
}
|
||||
|
||||
|
||||
@ -262,7 +262,7 @@ B rank_c1(Md2D* d, B x) { B f = d->f; B g = d->g;
|
||||
|
||||
if (cr>1) ptr_dec(csh);
|
||||
usz* rsh = HARR_FA(r, k);
|
||||
if (k>1) memcpy(rsh, xsh, k*sizeof(usz));
|
||||
if (k>1) shcpy(rsh, xsh, k);
|
||||
|
||||
decG(x);
|
||||
return bqn_merge(HARR_O(r).b);
|
||||
|
||||
@ -34,7 +34,7 @@ B select_c2(B t, B w, B x) {
|
||||
usz wi = WRAP(o2i64(w), cam, thrF("⊏: Indexing out-of-bounds (𝕨≡%R, %s≡≠𝕩)", w, cam));
|
||||
Arr* r = TI(x,slice)(incG(x), wi*csz, csz);
|
||||
usz* sh = arr_shAlloc(r, xr-1);
|
||||
if (sh) memcpy(sh, a(x)->sh+1, (xr-1)*sizeof(usz));
|
||||
if (sh) shcpy(sh, a(x)->sh+1, xr-1);
|
||||
decG(x);
|
||||
return taga(r);
|
||||
}
|
||||
@ -144,8 +144,8 @@ B select_c2(B t, B w, B x) {
|
||||
Arr* ra = mut_fp(r);
|
||||
usz* rsh = arr_shAlloc(ra, rr);
|
||||
if (rsh) {
|
||||
memcpy(rsh , a(w)->sh , wr *sizeof(usz));
|
||||
memcpy(rsh+wr, a(x)->sh+1, (xr-1)*sizeof(usz));
|
||||
shcpy(rsh , a(w)->sh , wr );
|
||||
shcpy(rsh+wr, a(x)->sh+1, xr-1);
|
||||
}
|
||||
decG(w); decG(x);
|
||||
return withFill(taga(ra),xf);
|
||||
|
||||
@ -754,7 +754,7 @@ B join_c1(B t, B x) {
|
||||
usz* sh = arr_shAlloc((Arr*)r.c, ir);
|
||||
if (sh) {
|
||||
sh[0] = 0;
|
||||
memcpy(sh+1, a(xf)->sh+1, sizeof(usz)*(ir-1));
|
||||
shcpy(sh+1, a(xf)->sh+1, ir-1);
|
||||
}
|
||||
dec(xf);
|
||||
return withFill(r.b, xff);
|
||||
@ -792,7 +792,7 @@ B join_c1(B t, B x) {
|
||||
usz* sh = arr_shAlloc(ra, ir);
|
||||
if (sh) {
|
||||
sh[0] = cam;
|
||||
memcpy(sh+1, x0sh+1, sizeof(usz)*(ir-1));
|
||||
shcpy(sh+1, x0sh+1, ir-1);
|
||||
}
|
||||
decG(x);
|
||||
return SFNS_FILLS? qWithFill(taga(ra), rf) : taga(ra);
|
||||
@ -848,7 +848,7 @@ B couple_c1(B t, B x) {
|
||||
usz ia = a(x)->ia;
|
||||
Arr* r = TI(x,slice)(incG(x),0, ia);
|
||||
usz* sh = arr_shAlloc(r, rr+1);
|
||||
if (sh) { sh[0] = 1; memcpy(sh+1, a(x)->sh, rr*sizeof(usz)); }
|
||||
if (sh) { sh[0] = 1; shcpy(sh+1, a(x)->sh, rr); }
|
||||
decG(x);
|
||||
return taga(r);
|
||||
}
|
||||
@ -865,7 +865,7 @@ B couple_c2(B t, B w, B x) {
|
||||
mut_copyG(r, ia, x, 0, ia);
|
||||
Arr* ra = mut_fp(r);
|
||||
usz* sh = arr_shAlloc(ra, wr+1);
|
||||
if (sh) { sh[0]=2; memcpy(sh+1, a(w)->sh, wr*sizeof(usz)); }
|
||||
if (sh) { sh[0]=2; shcpy(sh+1, a(w)->sh, wr); }
|
||||
if (!SFNS_FILLS) { decG(w); decG(x); return taga(ra); }
|
||||
B rf = fill_both(w, x);
|
||||
decG(w); decG(x);
|
||||
@ -1156,7 +1156,7 @@ B transp_c1(B t, B x) {
|
||||
rsh[0] = w;
|
||||
rsh[1] = h;
|
||||
} else {
|
||||
memcpy(rsh, xsh+1, (xr-1)*sizeof(usz));
|
||||
shcpy(rsh, xsh+1, xr-1);
|
||||
rsh[xr-1] = h;
|
||||
}
|
||||
decG(x); return qWithFill(p.b, xf);
|
||||
@ -1167,7 +1167,7 @@ B transp_c1(B t, B x) {
|
||||
rsh[0] = w;
|
||||
rsh[1] = h;
|
||||
} else {
|
||||
memcpy(rsh, xsh+1, (xr-1)*sizeof(usz));
|
||||
shcpy(rsh, xsh+1, xr-1);
|
||||
rsh[xr-1] = h;
|
||||
}
|
||||
decG(x); return taga(r);
|
||||
|
||||
@ -1059,7 +1059,7 @@ B bitcast_impl(B el0, B el1, B x) {
|
||||
if (shObj(r)->refc>1) {
|
||||
shObj(r)->refc--; // won't go to zero as refc>1; preparation for being overwritten by new shape
|
||||
usz* zsh = arr_shAlloc(a(r), xr);
|
||||
memcpy(zsh, sh, (xr-1)*sizeof(usz));
|
||||
shcpy(zsh, sh, xr-1);
|
||||
sh = zsh;
|
||||
}
|
||||
sh[xr-1]=zl;
|
||||
|
||||
@ -743,8 +743,8 @@ B bqn_merge(B x) {
|
||||
if (xr+xfr > UR_MAX) thrM(">: Result rank too large");
|
||||
usz* rsh = arr_shAlloc(r, xr+xfr);
|
||||
if (rsh) {
|
||||
memcpy (rsh , a(x)->sh, xr *sizeof(usz));
|
||||
if(xfr)memcpy(rsh+xr, a(xf)->sh, xfr*sizeof(usz));
|
||||
shcpy (rsh , a(x )->sh, xr);
|
||||
if(xfr)shcpy(rsh+xr, a(xf)->sh, xfr);
|
||||
}
|
||||
decG(x); dec(xf);
|
||||
return taga(r);
|
||||
@ -771,8 +771,8 @@ B bqn_merge(B x) {
|
||||
Arr* ra = mut_fp(r);
|
||||
usz* rsh = arr_shAlloc(ra, xr+elR);
|
||||
if (rsh) {
|
||||
memcpy (rsh , a(x)->sh, xr *sizeof(usz));
|
||||
if (elSh)memcpy(rsh+xr, elSh, elR*sizeof(usz));
|
||||
shcpy (rsh , a(x)->sh, xr);
|
||||
if (elSh)shcpy(rsh+xr, elSh, elR);
|
||||
}
|
||||
decG(x);
|
||||
return withFill(taga(ra),fill);
|
||||
|
||||
@ -77,7 +77,7 @@ static void arr_shCopy(Arr* n, B o) { // copy shape & rank from o to n
|
||||
n->sh = a(o)->sh;
|
||||
}
|
||||
}
|
||||
static void shcpy(usz* dst, usz* src, usz len) {
|
||||
static void shcpy(usz* dst, usz* src, size_t len) {
|
||||
memcpy(dst, src, len*sizeof(usz));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user