QML Performance Tips
Aaron J. Seigo
aseigo at kde.org
Tue Nov 1 10:15:15 UTC 2011
On Tuesday, November 1, 2011 10:45:27 Sebastian Kügler wrote:
> http://harmattan-
> dev.nokia.com/docs/library/html/guide/html/Developer_Library_Best_practices_
> for_application_development_QML_performance_tips_and_tricks.html
some nice points in there indeed ..
i did spot a common programming error in the last bit on container usage,
however:
QStringList nameList=myClass.nameList();
if ( nameList.first()==searchName ) {
...
}
first() and at(0) will both trigger asserts / crash if the list is empty. if
using first() or at(0) always do it like this:
if (!nameList.isEmpty() && nameList.at(0) == searchName())
at(int) assumes a valid index (for performance reasons) similar to how arrays
in C do. this has hit people many times in plasma code. watch out :)
also, when iterating a list i usually just use Q*Iterator with their java-
style notation. they are harder to get wrong, the code is shorter and easier
to read and the overhead is nominal.
--
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43
KDE core developer sponsored by Qt Development Frameworks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/active/attachments/20111101/64d96278/attachment.sig>
More information about the Active
mailing list