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

Marc Mutz marc.mutz at kdab.com
Fri Jul 10 15:39:14 CEST 2015


On Friday 10 July 2015 14:19:54 Andreas Aardal Hanssen wrote:
> > On 10 Jul 2015, at 14:58, Marc Mutz <marc.mutz at kdab.com> wrote:
> > 
> > On Friday 10 July 2015 13:37:40 Andreas Aardal Hanssen wrote:
> >> QList<QImage>.
> > 
> > You just proved my point. sizeof(QImage) > sizeof(void*). If even you as
> > a long-time Troll don't understand what QList actually does, there's a
> > problem. Don't you agree?
> 
> At the very worst it would be a bug if QList created a list of pointers to
> new QImages. I can’t say when that bug was introduced though.

It was introduced with the introduction of QList. :)

Maybe QList<QImage> outperforms Q3ValueList<QImage>, but QImage is most 
certainly not in the QList sweet spot.

BTW: Even in that sweet spot, when QList<C> uses almost exactly the same 
memory layout as a QVector<C> (which, incidentally, invalidates your argument 
about QList being safer than QVector), it performs worse, probably because it 
has one more addition to perform to adjust for the prepend area.

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list