[Development] Help reviewing my own changes to QSharedPointer
Thiago Macieira
thiago.macieira at intel.com
Thu Jun 7 00:55:24 CEST 2012
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.
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.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Intel Sweden AB - Registration Number: 556189-6027
Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120607/c88adaee/attachment.sig>
More information about the Development
mailing list