Boost logo

Boost :

Subject: Re: [boost] [filesystem] windows/posix inconsistencies.
From: Beman Dawes (bdawes_at_[hidden])
Date: 2012-02-02 08:18:52


On Wed, Feb 1, 2012 at 10:21 AM, Dave Abrahams <dave_at_[hidden]> wrote:
>
> on Tue Jan 31 2012, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
>>...
>> Although returning vectors by value might be a good idea for
>> factories, and such things, it's always more efficient to pass a
>> reference to a vector, and clear() + fill or assign, or even better,
>> reusing already constructed values (which can be vectors of
>> vectors).
>
> Are there any numbers to back that claim up?  It seems obvious at first
> glance, of course, but sometimes reality surprises us.

I ran such a test a couple of years ago. While I've forgotten the
details, it had to do with how to pass back the result of string
encoding conversions for shortish strings. Return by value did
surprisingly well in the particular application.

Between optimizing compilers and aggressive CPU performance
optimizations, measurement is the only real way to know which is more
efficient.

--Beman


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