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

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to