CVS commit by mutz: From KDE_3_3_BRANCH: Speed up selectKeys() from O(NM) to O(MlogN+N) (M=#selectedKeys, N=#keys) by using itemMap once more. And simplify the code _a lot_ :) M +4 -14 keyselectiondialog.cpp 1.28 --- kdepim/certmanager/lib/ui/keyselectiondialog.cpp #1.27:1.28 @@ -531,20 +531,10 @@ void Kleo::KeySelectionDialog::startKeyL static void selectKeys( Kleo::KeyListView * klv, const std::vector & selectedKeys ) { + klv->clearSelection(); if ( selectedKeys.empty() ) return; - int selectedKeysCount = selectedKeys.size(); - for ( Kleo::KeyListViewItem * item = klv->firstChild() ; item ; item = item->nextSibling() ) { - const char * fpr = item->key().primaryFingerprint(); - if ( !fpr || !*fpr ) - continue; for ( std::vector::const_iterator it = selectedKeys.begin() ; it != selectedKeys.end() ; ++it ) - if ( qstrcmp( fpr, it->primaryFingerprint() ) == 0 ) { + if ( Kleo::KeyListViewItem * item = klv->itemByFingerprint( it->primaryFingerprint() ) ) item->setSelected( true ); - if ( --selectedKeysCount <= 0 ) - return; - else - break; - } - } }