dstv[dest_i] = srcv[src_i];
}
-static u64 get_num(const void *a, int i)
-{
- struct bucket_item *av = (struct bucket_item *)a;
- return av[i].count;
-}
-
/*
* Use 4 bits as radix base
* Use 16 u32 counters for calculating new possition in buf array
* @array_buf - buffer array to store sorting results
* must be equal in size to @array
* @num - array size
- * @get_num - function to extract number from array
* @copy_cell - function to copy data from array to array_buf and vice versa
* @get4bits - function to get 4 bits from number at specified offset
*/
-static void radix_sort(void *array, void *array_buf, int num,
- u64 (*get_num)(const void *, int i),
+static void radix_sort(struct bucket_item *array, struct bucket_item *array_buf,
+ int num,
void (*copy_cell)(void *dest, int dest_i,
void* src, int src_i),
u8 (*get4bits)(u64 num, int shift))
* Try avoid useless loop iterations for small numbers stored in big
* counters. Example: 48 33 4 ... in 64bit array
*/
- max_num = get_num(array, 0);
+ max_num = array[0].count;
for (i = 1; i < num; i++) {
- buf_num = get_num(array, i);
+ buf_num = array[i].count;
if (buf_num > max_num)
max_num = buf_num;
}
memset(counters, 0, sizeof(counters));
for (i = 0; i < num; i++) {
- buf_num = get_num(array, i);
+ buf_num = array[i].count;
addr = get4bits(buf_num, shift);
counters[addr]++;
}
counters[i] += counters[i - 1];
for (i = num - 1; i >= 0; i--) {
- buf_num = get_num(array, i);
+ buf_num = array[i].count;
addr = get4bits(buf_num, shift);
counters[addr]--;
new_addr = counters[addr];
memset(counters, 0, sizeof(counters));
for (i = 0; i < num; i ++) {
- buf_num = get_num(array_buf, i);
+ buf_num = array_buf[i].count;
addr = get4bits(buf_num, shift);
counters[addr]++;
}
counters[i] += counters[i - 1];
for (i = num - 1; i >= 0; i--) {
- buf_num = get_num(array_buf, i);
+ buf_num = array_buf[i].count;
addr = get4bits(buf_num, shift);
counters[addr]--;
new_addr = counters[addr];
struct bucket_item *bucket = ws->bucket;
/* Sort in reverse order */
- radix_sort(ws->bucket, ws->bucket_b, BUCKET_SIZE, get_num, copy_cell,
+ radix_sort(ws->bucket, ws->bucket_b, BUCKET_SIZE, copy_cell,
get4bits);
for (i = 0; i < BYTE_CORE_SET_LOW; i++)