[kgraphviewer-devel] optimize map loops
Milian Wolff
mail at milianw.de
Sun Nov 7 16:22:10 CET 2010
Hey Gael,
Albert reviewed parts of kgraphviewer and spotted things like this:
QList<QString> edgesKeys = edges().keys();
foreach (const QString& eid, edgesKeys)
{
GraphEdge* edge = edges()[eid];
This is like the worst possible way to iterate over maps you can imagine.
Instead you should write it like this:
QMap<QString, GraphEdge*>::const_iterator it = edges().constBegin();
while (it != edges().constEnd()) {
// use it.value() and it.key() here
++it;
}
Though looking at the sources, one can even rewrite them much simpler, I'll
commit it, please review it then.
Bye
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kgraphviewer-devel/attachments/20101107/11902bef/attachment.sig
More information about the kgraphviewer-devel
mailing list