[patch] KConfig: Efficient iterators

Thiago Macieira thiago at kde.org
Tue Apr 22 20:39:46 BST 2008


Aaron J. Seigo wrote:
>On Tuesday 22 April 2008, Thiago Macieira 
wrote:kdecore/config/kconfigdata.h:
>> Q_DECLARE_TYPEINFO(KEntryKey, Q_MOVABLE_TYPE)
>
>oooh.. that's very cool, and extremely handy to know about. thanks =)
>
>(it also reminds me about the new && variable type feature in c++0x,
> which seems like a generic mechanism for this same thing)

I've just remembered an issue to be careful with:

Declaring a type to be movable *could* be binary incompatible. It depends 
on whether the type is also large (> sizeof(void*)) or not. The breakage 
happens in QList because a movable type that fits inside a void* gets 
allocated inside the QList internal array itself, doing away with an 
extra allocation per item in the list.

We caught this issue in QSharedDataPointer and 
QExplicitlySharedDataPointer. We tried to do the right thing and make it 
movable, but that broke KDE code that was using those classes in a way 
that wasn't intended.

In any case, I was premature in my recommendation. QMap and QHash don't 
care about movable -- that's mostly for QVector and QList. Especially for 
QVector.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080422/a4366aff/attachment.sig>


More information about the kde-core-devel mailing list