There is a quirk (almost a bug?) in FreeBSD's qsort where it will switch to insertsort for the whole array under certain conditions, which we hit in production given how our data was arranged.
Did a bit of digging and found that there used to be a comment for why it was done, but it got removed [0] when they switched to the implementation from Bentley & McIlroy's "engineering a sort function" [1] around 1992.
I like how someone felt the need to write out insertion sort in some 4 line code golf challenge in the midst of qsort. This right here is why no one wants to deal with C anymore.
erk__|2 years ago
[0]: https://github.com/weiss/original-bsd/commit/d3fcf71e0db57cb...
[1]: https://cs.fit.edu/~pkc/classes/writing/papers/bentley93engi...
stefan_|2 years ago