Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 1999-11-27 17:54:25


Dave Abrahams wrote on 11/27/99 5:37 PM
>And has anyone done any actual _measurement_ to find out if the supposed
>optimization is *really* an optimization? For example, contrary to
>assumptions I've seen posted to this list, I would bet that long long is
>really best passed by value most of the time. If you have a const T&
>parameter and there's a non-inlined function call anywhere in the function's
>body, the parameter still has to be reloaded from memory after the call,
>where it might otherwise have lived in a register or two.

Hi Dave!

I haven't done any measurement, but I don't feel too bad about that.
Whether long long should be passed by value or by const& is a detail that
may even vary from machine to machine. But I can say with some certainty
that there will be types small enough that they should be passed by
value, and others large enough that they should be passed by const&.
long long can always be specialized for a particular machine if it does
not fit the general rule (this will probably frequently be true of
double). And if the "IsSmallAndFast" pattern is used, even the general
rule can be easily customized.

You're a few steps ahead of us. We're fairly convinced that the
call_traits idea has merit. We're still trying to figure out generally
how to best implement it. But we haven't gotten to the stage of being
able to say with any certainty exactly what types should do what ('cept
for maybe array types which Beman and Dietmar are working on for the
make_pair patch).

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk