Skip to content

Comment on GCC and C vs C++ Speed, Measured

Comments

Interesting aside: There are some things that are faster in C++ than C, for example the standard library sort functions are massively faster because the compiler can in-line the comparison.

Well, yes you are correct. However if you need the fastest sorting you're probably gonna inline the comparison regardless of language. If qsort is slow due to the function pointer comparison just move it inline manually.

The performance is the same if you put the qsort implementation in a header.

http://www.agottem.com/blog/inlining_qsort_sort

or use link-time compile generation (slow, and it might not work for huge projects like gcc/webkit, but if split into shared modules it can)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.