[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO
Marc Mutz
marc.mutz at kdab.com
Fri Jul 10 17:32:10 CEST 2015
On Friday 10 July 2015 14:48:26 Smith Martin wrote:
> but I generally don'[[t try to optimize until I have a working model.
This is not premature optimisation. This is avoiding premature pessimisation
(google it!).
QVector has exactly the same API these days as QList (except that QVector
requires a default ctor and QList doesn't; if something else is missing,
shout), so code using QVector is equally readable as code using QList. If that
is the case, the more efficient alternative is what should naturally flow out
of your fingers.
And another thing: By using a QVector, not only do you avoid an additional
heap allocation per element inserted, you also avoid readers of your code
guessing whether you're using the QList for its list features (like the
QList<Page> in QToolBoxPrivate - go, read it, it's subtle!) or just as a
container.
--
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