3 ms·
Does the necessary pointer casting in the implementations also make it slower than it should be (the specialized versions generated by compilers that support ge
by brabel 4y ago
Does the necessary pointer casting in the implementations also make it slower than it should be (the specialized versions generated by compilers that support generics wouldn't have any casting)?
- eptcyka 4y agoIts not the pointer casting, its the indirect function call that probably can be cached but it will always be another memory location that the CPU will need to jump to.
- jjnoakes 4y agoIf the compare function is inlined into the qsort() body, there wouldn't need to be any function call. I think that was the point of the question above.
- OnACoffeeBreak 4y agoThe way to answer this question is to look at the assembly code generated by the compiler with various optimization levels and see whether the compiler ever inlines the compare function. https://godbolt.org/ https://godbolt.org/ might be useful for this exercise.
- jjnoakes 4y agoDid you reply to the right comment?