File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments