3 ms·
Calling an ordinary class member function in C++ has exactly the same overhead as calling a function in C. Modern compilers make the same optimization for func
by cperciva 9y ago
Calling an ordinary class member function in C++ has exactly the same overhead as calling a function in C.
Modern compilers make the same optimization for function pointers which are only ever set to one value, too.
- nly 9y agoHi Colin. This isn't an optimisation though, it's a guarantee. Member function calls are resolved statically at compile-time. Replacing indirect calls off a function pointer with direct calls (devirtualization) is an optimisation that applies to both languages equally and requires whole-program / link-time optimization.