File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change 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,13 +43,10 @@ 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
50- counts [i ] = cumSum ;
51- cumSum += tmp ;
52- }
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 ];
5350 } // leaves cumSum==n && 0<i && i<=width
5451
5552 tmp = in ;
@@ -71,10 +68,9 @@ static void dradix_r( // single-threaded recursive worker
7168 return ;
7269 }
7370
74- cumSum = 0 ;
75- for (int i = 0 ; cumSum < n ; ++ i ) { // again, cumSum<n better than i<width as it can return early
71+ for (uint64_t i = 0 , cumSum = 0 ; cumSum < n ; i ++ ) { // again, cumSum<n better than i<width as it can return early
7672 if (counts [i ] == 0 ) continue ;
77- uint64_t thisN = counts [i ] - cumSum ; // undo cummulate; i.e. diff
73+ const uint64_t thisN = counts [i ] - cumSum ; // undo cummulate; i.e. diff
7874 if (thisN <= INSERT_THRESH ) {
7975 dinsert (in + cumSum , thisN ); // for thisN==1 this'll return instantly. Probably better than several branches here.
8076 } else {
You can’t perform that action at this time.
0 commit comments