From kde-commits Wed Oct 27 15:03:23 2004 From: Marc Mutz Date: Wed, 27 Oct 2004 15:03:23 +0000 To: kde-commits Subject: kdepim/certmanager/lib/ui Message-Id: <20041027150323.5D87E16C23 () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=109888941226655 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; - } - } }