Skip to content

Commit 6a65009

Browse files
committed
reverting to old draft for testing
1 parent ca21c52 commit 6a65009

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/fsort.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ static void dradix_r( // single-threaded recursive worker
4343
return;
4444
}
4545

46-
for (uint64_t i = 0, cumSum = 0; cumSum < n; ++i) { // cumSum<n better than i<width as may return early
47-
if (!counts[i]) continue; // don't cumulate through 0s, important below to save a wasteful memset to zero
48-
counts[i] = cumSum;
49-
cumSum += counts[i];
46+
uint64_t cumSum=0;
47+
for (uint64_t i=0; cumSum<n; ++i) { // cumSum<n better than i<width as may return early
48+
uint64_t tmp;
49+
if ((tmp=counts[i])) { // don't cumulate through 0s, important below to save a wasteful memset to zero
50+
counts[i] = cumSum;
51+
cumSum += tmp;
52+
}
5053
} // leaves cumSum==n && 0<i && i<=width
5154

5255
tmp=in;
@@ -68,9 +71,10 @@ static void dradix_r( // single-threaded recursive worker
6871
return;
6972
}
7073

71-
for (uint64_t i = 0, cumSum = 0; cumSum < n; i++) { // again, cumSum<n better than i<width as it can return early
74+
cumSum=0;
75+
for (int i=0; cumSum<n; ++i) { // again, cumSum<n better than i<width as it can return early
7276
if (counts[i] == 0) continue;
73-
const uint64_t thisN = counts[i] - cumSum; // undo cummulate; i.e. diff
77+
uint64_t thisN = counts[i] - cumSum; // undo cummulate; i.e. diff
7478
if (thisN <= INSERT_THRESH) {
7579
dinsert(in+cumSum, thisN); // for thisN==1 this'll return instantly. Probably better than several branches here.
7680
} else {

0 commit comments

Comments
 (0)