use reshape_one instead of manual mut_fill more

This commit is contained in:
dzaima 2025-06-11 17:27:02 +03:00
parent abb9adbc50
commit 634cf82fbe
3 changed files with 11 additions and 9 deletions

View File

@ -362,9 +362,7 @@ static NOINLINE B to_fill_cell(B x, ur k, u32 chr) { // consumes x
usz* sh = SH(x)+k;
usz csz = 1;
for (usz i=0; i<cr; i++) if (mulOn(csz, sh[i])) thrF("%c: Empty argument too large (%H ≡ ≢𝕩)", chr, x);
MAKE_MUT(fc, csz);
mut_fill(fc, 0, xf, csz); dec(xf);
Arr* ca = mut_fp(fc);
Arr* ca = reshape_one(csz, xf);
usz* csh = arr_shAlloc(ca, cr);
if (cr>1) shcpy(csh, sh, cr);
decG(x);

View File

@ -368,10 +368,10 @@ B scan_c2(Md1D* d, B w, B x) { B f = d->f;
if (ia==0) { dec(w); return x; }
if (RARE(!isFun(f))) {
if (isMd(f)) thrM("Calling a modifier");
Arr* ra = arr_shCopy(reshape_one(ia, inc(f)), x);
B xf = getFillR(x);
MAKE_MUT(rm, ia);
mut_fill(rm, 0, f, ia);
return withFill(mut_fcd(rm, x), xf);
decG(x);
return withFill(taga(ra), xf);
}
u8 xe = TI(x,elType);
if (RTID(f) != RTID_NONE) {

View File

@ -40,9 +40,13 @@ B eachd_fn(B fo, B w, B x, FC2 f) {
if (ria==0) {
rb = rM==1? emptyHVec() : m_harrUc(bo).b;
} else if (f == arr_c2) {
MAKE_MUT(rm, ria);
mut_fill(rm, 0, fo, ria);
rb = mut_fc(rm, bo);
if (EACH_FILLS) {
rb = taga(arr_shCopy(reshape_one(ria, inc(fo)), bo));
} else {
MAKE_MUT(rm, ria);
mut_fill(rm, 0, fo, ria);
rb = mut_fc(rm, bo);
}
} else {
M_HARR(r, ria)
if (wr==xr) { SGet(x) SGet(w) for(usz ri=0; ri<ria; ri++) HARR_ADD(r, ri, f(fo, Get(w,ri), Get(x,ri))); }