From: Giovanni P. Deretta (gpderetta_at_[hidden])
Date: 2006-05-02 14:46:46
Thorsten Ottosen wrote:
> Doug Gregor wrote:
>> On May 2, 2006, at 1:01 PM, Neal Becker wrote:
>>> David Abrahams wrote:
>>>> Actually it's not a virtual call, it's a call through a function
>>>> pointer. That's one less indirection.
>>> Do you think a smart compiler might optimize this to a direct call?
>> I have yet to see a compiler smart enough to optimize this indirection.
> IOW, the overhead might be *significant* for small functions that would
> otherwise be inlined (and insignificant for larger functions).
Exactly. I've done some tests in the past trying to quantify the cost of
virtuals, direct functions (inlined and not) and indirect functions.
The cost of an indirect function is in practice not distinguishable from
a non-inlined direct function. A virtual is (very) slightly costlier.
The real difference is in inlining.
-- Giovanni P. Deretta
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk