11#include "data.table.h"
22
3- #define INSERT_THRESH 200 // TODO: expose via api and test
3+ static const int INSERT_THRESH = 200 ; // TODO: expose via api and test
44
55static void dinsert (double * x , const int n ) { // TODO: if and when twiddled, double => ull
66 if (n < 2 ) return ;
@@ -43,17 +43,16 @@ static void dradix_r( // single-threaded recursive worker
4343 return ;
4444 }
4545
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
46+ for (uint64_t i = 0 , cumSum = 0 ; cumSum < n ; i ++ ) { // cumSum<n better than i<width as may return early
47+ uint64_t tmp = counts [i ];
48+ if (tmp ) { // don't cumulate through 0s, important below to save a wasteful memset to zero
5049 counts [i ] = cumSum ;
5150 cumSum += tmp ;
5251 }
5352 } // leaves cumSum==n && 0<i && i<=width
5453
5554 tmp = in ;
56- for (uint64_t i = 0 ; i < n ; ++ i ) { // go forwards not backwards to give cpu pipeline better chance
55+ for (uint64_t i = 0 ; i < n ; ++ i ) { // go forwards not backwards to give cpu pipeline better chance
5756 int thisx = (* (uint64_t * )tmp - minULL ) >> fromBit & mask ;
5857 working [ counts [thisx ]++ ] = * tmp ;
5958 tmp ++ ;
@@ -71,8 +70,7 @@ static void dradix_r( // single-threaded recursive worker
7170 return ;
7271 }
7372
74- cumSum = 0 ;
75- for (int i = 0 ; cumSum < n ; ++ i ) { // again, cumSum<n better than i<width as it can return early
73+ for (uint64_t i = 0 , cumSum = 0 ; cumSum < n ; i ++ ) { // again, cumSum<n better than i<width as it can return early
7674 if (counts [i ] == 0 ) continue ;
7775 uint64_t thisN = counts [i ] - cumSum ; // undo cummulate; i.e. diff
7876 if (thisN <= INSERT_THRESH ) {
0 commit comments