move out another s+↕n loop

This commit is contained in:
dzaima 2023-05-05 13:28:58 +03:00
parent 14ca835fa2
commit cc94ec4cbc
2 changed files with 8 additions and 4 deletions

View File

@ -12,9 +12,12 @@ NOINLINE B intRange16(ux s, ux n) { // s+↕n with i16arr result
for (ux i = 0; i < n; i++) rp[i] = (i16)s + (i16)i;
return r;
}
NOINLINE void intRange32Fill(i32* xp, ux s, ux n) { // fill xp with s+↕n
for (ux i = 0; i < n; i++) xp[i] = (i32)s + (i32)i;
}
NOINLINE B intRange32(ux s, ux n) { // s+↕n with i32arr result
i32* rp; B r = m_i32arrv(&rp, n);
for (ux i = 0; i < n; i++) rp[i] = (i32)s + (i32)i;
intRange32Fill(rp, s, n);
return r;
}
NOINLINE B intRangeF64(ux s, ux n) { // s+↕n with f64arr result

View File

@ -427,8 +427,9 @@ B rand_range_c2(B t, B w, B x) {
extern Arr* bitUD[3]; // from fns.c
extern B bit2x[2];
NOINLINE B intRange16(ux s, ux n);
NOINLINE B intRange32(ux s, ux n);
B intRange16(ux s, ux n);
B intRange32(ux s, ux n);
void intRange32Fill(i32* xp, ux s, ux n);
B rand_deal_c1(B t, B x) {
i32 xi = o2i(x);
@ -497,7 +498,7 @@ B rand_deal_c1(B t, B x) {
b+= l;
}
TFREE(pos)
for (usz j=i; j<n; j++) rp[j] = j;
intRange32Fill(rp+i, i, n-i);
for (; i < n; i++) {
usz j = wy2u0k(wyrand(&seed), 1+i);
usz c=rp[j]; rp[j]=rp[i]; rp[i]=c;