Re:Never trust a programmer who says he knows C++
by VBprogrammer on Tuesday March 30, 2010 @07:51AM
(#1228864)
That is only a problem if and only if that method is being called in a very tight loop and its body is not particularly time consuming. A person making optimisations like this without first timing the code or at the very least spending some time introspecting on the pros and cons of doing so would not be someone I wanted to work with!
What's your problem with this answer? Non-virtual methods can be easily inlined, whereas virtual methods (almost always) require:
1. a load (though a hoistable one) from the vtable
2. an indirect branch
3. register re-allocation
4. function call overhead (standard prologue/epilogue)