No need to initialize the negative half of the counts table
This commit is contained in:
parent
37af32d95c
commit
44c0baee05
@ -720,38 +720,39 @@ B slash_im(B t, B x) {
|
|||||||
decG(x); return num_squeeze(r);
|
decG(x); return num_squeeze(r);
|
||||||
}
|
}
|
||||||
#define CASE_SMALL(N) \
|
#define CASE_SMALL(N) \
|
||||||
case el_i##N: { \
|
case el_i##N: { \
|
||||||
i##N* xp = i##N##any_ptr(x); \
|
i##N* xp = i##N##any_ptr(x); \
|
||||||
usz m=1<<N; \
|
usz m=1<<N; \
|
||||||
B r; \
|
B r; \
|
||||||
if (xia < m/2) { \
|
if (xia < m/2) { \
|
||||||
usz a=1; u##N max=xp[0]; \
|
usz a=1; u##N max=xp[0]; \
|
||||||
if (xp[0]<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
if (xp[0]<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
||||||
if (xia < m/2) { \
|
if (xia < m/2) { \
|
||||||
a=1; while (a<xia && xp[a]>xp[a-1]) a++; \
|
a=1; while (a<xia && xp[a]>xp[a-1]) a++; \
|
||||||
max=xp[a-1]; \
|
max=xp[a-1]; \
|
||||||
if (a==xia) { /* Sorted unique argument */ \
|
if (a==xia) { /* Sorted unique argument */ \
|
||||||
usz ria = max + 1; \
|
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<xia; i++) bitp_set(rp, xp[i], 1); \
|
for (usz i=0; i<BIT_N(ria); i++) rp[i]=0; \
|
||||||
decG(x); return r; \
|
for (usz i=0; i<xia; i++) bitp_set(rp, xp[i], 1); \
|
||||||
} \
|
decG(x); return r; \
|
||||||
} \
|
} \
|
||||||
for (usz i=a; i<xia; i++) { u##N c=xp[i]; if (c>max) max=c; } \
|
} \
|
||||||
if ((i##N)max<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
for (usz i=a; i<xia; i++) { u##N c=xp[i]; if (c>max) max=c; } \
|
||||||
usz ria = max+1; \
|
if ((i##N)max<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
||||||
i##N* rp; r = m_i##N##arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0; \
|
usz ria = max+1; \
|
||||||
for (usz i = 0; i < xia; i++) rp[xp[i]]++; \
|
i##N* rp; r = m_i##N##arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0; \
|
||||||
} else { \
|
for (usz i = 0; i < xia; i++) rp[xp[i]]++; \
|
||||||
TALLOC(usz, t, m); usz* th = t+m/2; \
|
} else { \
|
||||||
for (usz j=0; j<m ; j++) t[j]=0; \
|
TALLOC(usz, t, m); \
|
||||||
for (usz i=0; i<xia; i++) th[xp[i]]++; \
|
for (usz j=0; j<m/2; j++) t[j]=0; \
|
||||||
for (usz j=0; j<m/2; j++) if (t[j]) thrM("/⁼: Argument cannot contain negative numbers"); \
|
for (usz i=0; i<xia; i++) t[(u##N)xp[i]]++; \
|
||||||
usz ria=0; for (usz s=0; s<xia; ria++) s+=th[ria]; \
|
t[m/2]=xia; usz ria=0; for (usz s=0; s<xia; ria++) s+=t[ria]; \
|
||||||
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=th[i]; \
|
if (ria>m/2) thrM("/⁼: Argument cannot contain negative numbers"); \
|
||||||
TFREE(t); \
|
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); \
|
} \
|
||||||
|
decG(x); return num_squeeze(r); \
|
||||||
}
|
}
|
||||||
CASE_SMALL(8) CASE_SMALL(16)
|
CASE_SMALL(8) CASE_SMALL(16)
|
||||||
#undef CASE_SMALL
|
#undef CASE_SMALL
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user