Re:D is being used for autonomous driving research – Audi an...
by jstimpfle on Wednesday June 26, 2019 @04:25AM
(#20282935)
2x is only for integers, of course. Often you'll have bigger structs to sort.
But anyway. If performance matters (it mostly doesn't; sorting is usually not a bottleneck), you can reap much more than 2x by various tricks
- Improve the data by adding easier to compare fields
- tailor sorting algorithm to the data (what machine types? can we optimize with CPU-specific assembly? Can we do radix sort?, etc)
- avoid the need for sorting altogether. Often, the data can be constructed in a better way such that it falls out sorted.
C has _Generic though which can do the same, it seems a bit unfair to be comparing an old method kept for backward compatibility with C89 with whatever version of c++ and the compiler gained this advantage.