don't assume select returns refcount 1 array

that probably would be a safe assumption right now, but who knows about the future; cpyWithShape should return back its argument directly if it already has refcount 1 anyway
This commit is contained in:
dzaima 2023-03-31 14:14:01 +03:00
parent 413b49de30
commit baa1281efe

View File

@ -345,8 +345,9 @@ B transp_c2(B t, B w, B x) {
else ind = M1C2(tbl, add, v, ind);
}
r = C2(select, ind, x);
if (rr>1) arr_shReplace(a(r), rr, sh);
else { decSh(v(r)); arr_shVec(a(r)); }
Arr* ra = cpyWithShape(r); r = taga(ra);
if (rr>1) arr_shReplace(ra, rr, sh);
else { decSh((Value*)ra); arr_shVec(ra); }
ret:;
TFREE(alloc);