[Development] [SPAM] How bad QList really is

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Apr 28 21:45:13 CEST 2020


On 28/04/2020 03.56, Giuseppe D'Angelo via Development wrote:
> 1) First and foremost, in Qt 6 QString, QByteArray, QVector, are bigger 
> than a pointer (3 times a pointer size). So, in Qt 6:
> 
> * either QList stays unchanged, and now we heap allocate each element 
> for those cases too (thus it's necessary to know how the above 
> statistics change); or
> 
> * QList gets adapted so that its internal array allocates 3 * 
> sizeof(void*) per element, so that e.g. Q6StringList won't require a 
> per-item allocation. This would then also avoid allocations for other 
> datatypes, e.g. QStringView, QImage, maybe QVariant and QColor; but of 
> course waste a ton of space for the ones which remain small (most of Qt 
> implicitly shared datatypes).

Uh... can't it allocate sizeof(T) if T meets some criteria? IOW, I don't 
see the second case penalizing smaller types unless the implementation 
is poorly done.

-- 
Matthew


More information about the Development mailing list