List Info

Thread: KConfig: Efficient iterators




KConfig: Efficient iterators
user name
2008-04-21 12:44:28
For review
I have encountered that every call took more than 1 second
and ~100% of CPU on 
my box, in debugging session for KMail (win32/msvc).
Strange.

Use KEntryMap::ConstIterator instead of foreach with
entryMap.keys().

Infinite loops may take just one second on your box too,
_but_ better to 
optimize them 


-- 
regards / pozdrawiam, Jaroslaw Staniek
  Sponsored by OpenOffice Polska (http://www.openoffice
.com.pl/en) to work on
  Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/ke
xi)
  KDE Libraries for MS Windows (http://windows.kde.org)

_______________________________________________
Kde-optimize mailing list
Kde-optimizekde.org
ht
tps://mail.kde.org/mailman/listinfo/kde-optimize

  
Re: KConfig: Efficient iterators
user name
2008-04-21 14:20:00
No need to cross-post to k-c-d IMHO.

Good catch; using foreach on keys() is just a way of making
things slow indeed.
> Infinite loops [...]
Obviously they were not infinite, they were "just"
slow due to creating a QStringList with all the keys in it.

On Monday 21 April 2008, Jarosław Staniek wrote:
> 
> -        KEntry entry = entryMap[key];
> +        KEntry entry = entryMap[ entryMapIt.key()
];

Shouldn't this simply be entryMapIt.value()?

Later on:
> +        if (entryMapIt.key().mKey.isNull() &&
!entryMapIt.key().mGroup.isEmpty() &&
> +            entryMapIt.key().mGroup !=
"<default>" &&
entryMapIt.key().mGroup != "$Version")
> +            groups <<
QString::fromUtf8(entryMapIt.key().mGroup);
So many repetitions of entryMapIt.key() make me wish for a
local variable equal to it 

-- 
David Faure, faurekde.org, sponsored by Trolltech to work on
KDE,
Konqueror (http://www.konqueror.org
), and KOffice (http://www.koffice.org).
_______________________________________________
Kde-optimize mailing list
Kde-optimizekde.org
ht
tps://mail.kde.org/mailman/listinfo/kde-optimize
Re: KConfig: Efficient iterators
user name
2008-04-21 15:18:36
And wouldn't a QHash be much more appropriate than a QMap?

_______________________________________________
Kde-optimize mailing list
Kde-optimizekde.org
ht
tps://mail.kde.org/mailman/listinfo/kde-optimize

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )