[Development] [SPAM] How bad QList really is

Matthew Woehlke mwoehlke.floss at gmail.com
Mon Apr 27 17:13:26 CEST 2020

On 25/04/2020 10.49, André Pönitz wrote:
> We all know the story that began with
>      "We knew for a long time that QList is not a good default
>      container, despite what the documentation claims. The problem
>      boils down to the fact that for a lot of types T, QList<T> is
>      needlessly inefficient by allocating elements on the heap and
>      storing pointers to them instead of storing the elements
>      in-place, like e.g. QVector does. Sometimes, for large and
>      complex types, that might be exactly what you want, but a
>      conservative estimate would put that chance at less than 5%." [1]
> I was curious how this "conservative" estimate of "less than 5%"
> manifests in real QList object instances in a real world example.

(Remainder elided)

Thanks for the analysis! However, it seems the major take-away is that 
"when QList acts like QVector, all is well"? It would be interesting to 
see a comparison that ignores all instances where QList is behaving like 

The other problem is that performance isn't the only story. Sometimes, 
reference stability is desired. AFAIK, the only containers in Qt¹ that 
provide this currently are QLinkedList and QMap.

(¹ I speak of Qt6, specifically. In Qt5, QHash could be added to that 
list, but no more.)


More information about the Development mailing list