Re: Optimisation, function returns, STL containers
From: lilburne (lilburne_at_godzilla.net)
Date: 11/12/03
- Previous message: Daniel Spangenberg: "Re: thisIsAMemberFunctionName vs this_is_a_member_function_name"
- In reply to: Victor Bazarov: "Re: Optimisation, function returns, STL containers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 Nov 2003 20:25:43 +0000
Victor Bazarov wrote:
> "Simon Elliott" <simon@nospam.demon.co.uk> wrote...
>
>>What optimisation do compilers typically provide when passing STL
>>containers around?
>
>
>>
>>In theory there's a whole lot of unnecessary copying going on here, in
>>the "push_back"s and the getBloggsList() return. How much of this is the
>>compiler allowed to optimise away?
>
>
> The construction of 'myBloggList' object is permitted to happen
> "in place" (see 12.8/15). It's called "return value optimisation".
>
Though it won't happen in assignments, so you'll need to be
carefull of any other statements like:
myBloggsList = getBloggsList();
which isn't a construction. But you should be aware of this
with any object that is returned by value.
- Previous message: Daniel Spangenberg: "Re: thisIsAMemberFunctionName vs this_is_a_member_function_name"
- In reply to: Victor Bazarov: "Re: Optimisation, function returns, STL containers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|