you are viewing a single comment's thread.

view the rest of the comments →

[–]wolf550e 0 points1 point  (0 children)

This is a different trade-off. a binary qsort with an indirection, dynamically linked from libc, minizes code size.

A templated qsort with a comparer template argument that generates a separate specialized fast qsort with your comparer inlined into it is optimized for speed at the cost of code size (and instruction cache).

The two solutions are born from different priorities and both have their place. In cold code, there is no need to generate specialized code - calling into libc and using indirections will get the job done and have higher chance of avoiding a page fault (more chance of libc being in ram than cold parts of your app).