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

Smith Martin Martin.Smith at theqtcompany.com
Sun Jul 12 10:13:30 CEST 2015


I'm trying to get information for updating the documentation for QList. At the moment, it is misleading, judging by what you are saying. Maintaining the documentation isn't a red herring. It's actually my job.

martin

________________________________________
From: development-bounces+martin.smith=theqtcompany.com at qt-project.org <development-bounces+martin.smith=theqtcompany.com at qt-project.org> on behalf of Marc Mutz <marc.mutz at kdab.com>
Sent: Sunday, July 12, 2015 2:03 AM
To: development at qt-project.org
Subject: Re: [Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

On Saturday 11 July 2015 21:50:05 Smith Martin wrote:
> Suppose (as in the use case that started this thread) that your
> QList/QVector/QLinkedList will only have a small number of elements in it.
> Almost always less than 5. Never more than about 8. Does this change the
> analysis at all? In particular, does it minimize the performance
> differences?
>
> And suppose the use case also assumes that you add all the elements to the
> container immediately and then you process the container sequentially
> immediately after that. So there is no inserting, no searching, and no
> other mallocs.

If you have only a very small number of elements, you should either be using a
QVarLengthArray to avoid _any_ container-related heap allocations, or else a
std::vector, because the overhead of the d-pointer is relatively-speaking a
lot higher at small element counts.

And please stop chasing red herrings. It was _not_ the use of
QList<ParsedSomething> in qdoc that originated this thread. Look at my Gerrit
list of changes, merged and open. And my blog post is five years old.

Thanks,
Marc

--
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
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list