KDE/kdelibs/kfile
David Faure
faure at kde.org
Fri Mar 20 02:08:11 CET 2009
SVN commit 941585 by dfaure:
Improve performance when marking a large amount of files as "cut". For Ctrl+A Ctrl+X on 5000 files:
- before this commit: 300s
- after not decoding the full clipboard for every item: 6-8s
- after also looking up into a QSet instead of a QList: 4-5s
(Cutting only one item in the 5000 takes 0.03s with the QList and 0.05s with the
QSet because of the time needed to build the set, but that's negligible)
CCMAIL: kde-optimize at kde.org
CCBUG: 185267
(but this only fixes performance, not the fact that X says "clipboard too big"
and truncates the list when pasting!)
M +5 -10 kfilepreviewgenerator.cpp
--- trunk/KDE/kdelibs/kfile/kfilepreviewgenerator.cpp #941584:941585
@@ -27,6 +27,7 @@
#include <kio/previewjob.h>
#include <kdirlister.h>
#include <kdirmodel.h>
+#include <kdebug.h>
#include <QApplication>
#include <QAbstractItemView>
@@ -687,15 +688,7 @@
{
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
const KUrl::List cutUrls = KUrl::List::fromMimeData(mimeData);
-
- const KUrl itemUrl = item.url();
- foreach (const KUrl& url, cutUrls) {
- if (url == itemUrl) {
- return true;
- }
- }
-
- return false;
+ return cutUrls.contains(item.url());
}
void KFilePreviewGenerator::Private::applyCutItemEffect()
@@ -706,6 +699,8 @@
return;
}
+ const QSet<KUrl> cutUrls = KUrl::List::fromMimeData(mimeData).toSet();
+
KFileItemList items;
KDirLister* dirLister = m_dirModel->dirLister();
const KUrl::List dirs = dirLister->directories();
@@ -715,7 +710,7 @@
DataChangeObtainer obt(this);
foreach (const KFileItem& item, items) {
- if (isCutItem(item)) {
+ if (cutUrls.contains(item.url())) {
const QModelIndex index = m_dirModel->indexForItem(item);
const QVariant value = m_dirModel->data(index, Qt::DecorationRole);
if (value.type() == QVariant::Icon) {
More information about the Kde-optimize
mailing list