[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-active
Subject:    Re: QML Performance Tips
From:       Sebastian =?utf-8?q?K=C3=BCgler?= <sebas () kde ! org>
Date:       2011-11-01 13:44:29
Message-ID: 201111011444.29745.sebas () kde ! org
[Download RAW message or body]

On Tuesday, November 01, 2011 11:15:15 Aaron J. Seigo wrote:
> 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_practic
> > es_ 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
> :)

Well spot. Not such a big issue in there, though, since the doc says "avoid 
this pattern", just one more reason to do so :)

> 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.

The good examples use iterators, yep.
-- 
sebas

http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9
_______________________________________________
Active mailing list
Active@kde.org
https://mail.kde.org/mailman/listinfo/active

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic