Hacker News new | ask | show | jobs
by Bromskloss 3665 days ago
What are we looking for in the qsort example? Is there a Rust equivalent we should compare to?
1 comments

The C code is forced to use a function pointer and hence do dynamic virtual calls for each comparison, while Rust and C++ can use generics/templates to get static dispatch (and hence inlining, constant folding etc.). You can see C vs. C++ in http://www.martin-ueding.de/en/programming/qsort/index.html , and Rust is likely to be similar to C++.
LTO will allow qsort to be inlined, etc.