[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Kevin Kofler kevin.kofler at chello.at
Tue Jul 28 00:59:02 CEST 2015


Thiago Macieira wrote:
> The total memory allocated for QList is always equal to or bigger than
> QVector for the same size, regardless of T. So in addition to having the
> same memory size, you access the data through one extra indirection.

I was talking about speed, not memory consumption.

> The only benefit QList has is that it's really quick to resize and insert
> at any point compared to a QVector of a complex or large type.

That was my point (especially the "insert at any point" case). (And you 
forgot "remove at any point", which is like "insert at any point" except for 
moving in the other direction.)

The speed difference can be arbitrarily large. Even infinite if the type is 
not movable and the copy constructor or the destructor does not halt. ;-)

        Kevin Kofler




More information about the Development mailing list