|
Boost : |
Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-03-15 15:47:28
Scott McMurray skrev:
> On Sun, Mar 15, 2009 at 14:34, Thorsten Ottosen
> <thorsten.ottosen_at_[hidden]> wrote:
>> Scott McMurray skrev:
>>> I agree that self-assignment is uncommon enough for an explicit check
>>> to be a pessimization, though. Is the algorithm you have ( the
>>> attachment to the first post in this thread doesn't have operator= )
>>> really more efficient than one that doesn't need the explicit check?
>> Here's the current version. I guess I would have to do some test to make
>> 100% sure it's faster.
>>
>
> I would be interested to see if the manual inlining (essentially)
> really does make a noticeable speedup. For small n it wouldn't
> surprise me if it did, though.
>
> The important part, though, is that what you have should work just
> fine for self-assignment. diff will be 0, so you go into the first
> if, pop_back nothing, and then copy over it with itself. So I think
> you actually wrote a self-assignment-safe version without realizing
> it.
No, because assign_impl() does memcpy() for pods which doesn't allow
overlapping ranges.
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk