[Development] Help reviewing my own changes to QSharedPointer

lars.knoll at nokia.com lars.knoll at nokia.com
Thu Jun 7 08:47:11 CEST 2012


On 6/7/12 12:55 AM, "ext Thiago Macieira" <thiago.macieira at intel.com>
wrote:

>On quarta-feira, 6 de junho de 2012 21.56.16, lars.knoll at nokia.com wrote:
>> >https://codereview.qt-project.org/26981-Optimisedeletion
>> 
>> I might be wrong (getting tired), but I think this reintroduces the
>> problem with forward declared pointers that the first patch fixes.
>
>It's a different solution.
>
>The Qt 4 solution for this was to return false from a virtual function
>(the 
>default implementation), which would require the caller to perform the
>deletion. The code was like this:
>
>	if (!d->destroy())
>		delete value;
>
>This function was called from deref(), which meant that where a reference
>could be dropped also required a full definition of the class.

Yes, that's what the first commit was fixing.
>
>The new optimisation does not introduce "delete value" into the reference-
>dropping code path. That is still:
>
>	d->destroy()
>which does:
>        void destroy() { destroyer(this); }
>	(destroyer is a function pointer)
>
>The optimisation simply changes what the pointed function does. Wiithout
>it, 
>it will call another stored function pointer. With it, it will call
>delete 
>directly.

You're right. My brain probably stopped working shortly before midnight.
Will review the remaining patches today as well.

Cheers,
Lars




More information about the Development mailing list