Yes, thanks for your blog, but I'm one of those responsible for Qt documentation. Currently, the Qt documentation for QList shows this:
"For most purposes, QList is the right class to use. Its index-based API is more convenient than QLinkedList's iterator-based API, and it is usually faster than QVector because of the way it stores its items in memory. It also expands to less code in your executable." Reading that, most users will use QList all the time. But I'm still not clear on one point. If I use QList<C>, and it is implemented as QList<C*> because my C is not a "good" C, why is this inefficent if the only copy of each C is the one that gets allocated on the heap? I just create the list to store things. It won't ever be moved. I will just process the list when it's time comes. Why is that inefficient? martin ________________________________________ From: [email protected] <[email protected]> on behalf of Marc Mutz <[email protected]> Sent: Friday, July 10, 2015 2:17 PM To: [email protected] Subject: Re: [Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO On Friday 10 July 2015 12:20:55 Smith Martin wrote: > I'm asking if QList<C> becomes QList<C*> even if I declare it as QList<C>. And I said in the initial mail: On Friday 10 July 2015 11:03:49 Marc Mutz wrote: > I won't give you the whole story (google "QList harmful" for that) Which you clearly haven't done. Otherwise you'd have found the first hit https://marcmutz.wordpress.com/2010/07/29/sneak-preview-qlist-considered- harmful/ whose second sentence reads: 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. But yes, Peppe already provided the TL;DR: *grmbl* He's the nicer of the two of us :) -- Marc Mutz <[email protected]> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - The Qt Experts _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
