No need to initialize the negative half of the counts table

This commit is contained in:
Marshall Lochbaum 2022-09-03 14:07:17 -04:00
parent 37af32d95c
commit 44c0baee05

View File

@ -732,7 +732,8 @@ B slash_im(B t, B x) {
max=xp[a-1]; \
if (a==xia) { /* Sorted unique argument */ \
usz ria = max + 1; \
u64* rp; r = m_bitarrv(&rp, ria); for (usz i=0; i<BIT_N(ria); i++) rp[i]=0; \
u64* rp; r = m_bitarrv(&rp, ria); \
for (usz i=0; i<BIT_N(ria); i++) rp[i]=0; \
for (usz i=0; i<xia; i++) bitp_set(rp, xp[i], 1); \
decG(x); return r; \
} \
@ -743,12 +744,12 @@ B slash_im(B t, B x) {
i##N* rp; r = m_i##N##arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0; \
for (usz i = 0; i < xia; i++) rp[xp[i]]++; \
} else { \
TALLOC(usz, t, m); usz* th = t+m/2; \
for (usz j=0; j<m ; j++) t[j]=0; \
for (usz i=0; i<xia; i++) th[xp[i]]++; \
for (usz j=0; j<m/2; j++) if (t[j]) thrM("/⁼: Argument cannot contain negative numbers"); \
usz ria=0; for (usz s=0; s<xia; ria++) s+=th[ria]; \
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=th[i]; \
TALLOC(usz, t, m); \
for (usz j=0; j<m/2; j++) t[j]=0; \
for (usz i=0; i<xia; i++) t[(u##N)xp[i]]++; \
t[m/2]=xia; usz ria=0; for (usz s=0; s<xia; ria++) s+=t[ria]; \
if (ria>m/2) thrM("/⁼: Argument cannot contain negative numbers"); \
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=t[i]; \
TFREE(t); \
} \
decG(x); return num_squeeze(r); \