Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-04-21 18:54:48


Daniel Frey:
> The attached patch optimizes the current implementation of
> enable_shared_from_this, it saves one plain pointer. That might not be
> very much, but it's a start. It is 100% compatible for the users, no
> features are dropped. Further improvements might be possible, but I
> think the attached patch is a good base.
>
> Peter, do you see any chance for it? If not, please tell me why and (if
> possible) what needs to be improved.

Your patch (still) contains a number of changes, some of which are unrelated
to its purpose (to save one pointer in esft). To break it down:

1. Changes esft.hpp to use the shared_count constructor to eliminate the
circular initialization instead of sp_accept_owner overload(
sp_deleter_wrapper* ). Stylistic change, not necessary, avoids testing a
possible use of the sp_accept_owner mechanism.

2. Changes shared_count(weak_count) to not throw. Arbitrary change, not
necessary, makes shared_count:weak_count inconsistent with
shared_ptr:weak_ptr.

3. Adds a move constructor to shared_count. OK, not essential, but
desirable.

4. Adds if( tmp != pi_ ) optimizations. OK, but a separate issue.

5. Adds shared_ptr(shared_count, p). OK, essential. The && overload is not
guarded, BTW.

6. Adds _internal_shared_count. OK, essential. Should probably be called
get_shared_count.

You may commit #4 right away; as for the rest, I'd really like to see the
patch without #1 and #2.


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