Remove random template and just make qsort be a wrapper around qsort_r Recurse only into the smaller partition. This removes the possibility of O(n) recursion in the worst case Use insertion sort for ranges shorter than 16 elements. Split qsort_swap into qsort_swap_fixed and qsort_swap_general - fixed one handles 1, 2, 4 and 8 byte elements which can be done directly with mov instructions - general copies 64 bytes at a time followed by a single copy for the rest. the 64 byte chunk loop gets nicely optimized into sse
16 KiB
16 KiB