This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Adding moving to basic_string


Jonathan Wakely wrote:

>Move semantics could make it as efficient as this (but less ugly):
>
>a = ((b+c) += d);
>  
>
Humm, maybe now I see your *real* point ;)

We arrive in both cases to the above situation. Then things are
completely different. In the move-semantics + short-string optimization
case, we can often spare reallocating (b+c) (if there is sufficient
space available for d too) but then the final assignment is expensive.
In the reference-counted case b+c is technically shared, unfortunately,
and will be always reallocated *during* operator+=; then the final
assignment is cheap.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]