[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kcoreaddons] src/lib/io: Use the much faster urls() method from QMimeData
From:       Jaime Torres <null () kde ! org>
Date:       2018-01-28 11:01:49
Message-ID: E1efkib-0006if-85 () code ! kde ! org
[Download RAW message or body]

Git commit 18e4d245d3d595cdc17ad40aa88495d6d2c30bf7 by Jaime Torres.
Committed on 28/01/2018 at 11:01.
Pushed by jtamate into branch 'master'.

Use the much faster urls() method from QMimeData

Summary:
When requesting a list of text/uri-list, use the much faster QMimeData
urls() method.
The unittests pass (the desktop: protocol) and
CCBUG: 342056
is half solved. The paste speed is as fast as drag&drop in local files
and with fish: files.
The lock in X11 plasma or kwin still needs another patch.

Test Plan: Select 2000 files in one folder, cut and paste them in another disk.

Reviewers: #frameworks, dfaure

Reviewed By: dfaure

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D10155

M  +6    -3    src/lib/io/kurlmimedata.cpp

https://commits.kde.org/kcoreaddons/18e4d245d3d595cdc17ad40aa88495d6d2c30bf7

diff --git a/src/lib/io/kurlmimedata.cpp b/src/lib/io/kurlmimedata.cpp
index fd2e6e7..498a8a4 100644
--- a/src/lib/io/kurlmimedata.cpp
+++ b/src/lib/io/kurlmimedata.cpp
@@ -73,9 +73,11 @@ QList<QUrl> KUrlMimeData::urlsFromMimeData(const QMimeData *mimeData,
     }
     QByteArray ba = mimeData->data(QString::fromLatin1(firstMimeType));
     if (ba.isEmpty()) {
-        ba = mimeData->data(QString::fromLatin1(secondMimeType));
-    }
-    if (!ba.isEmpty()) {
+        // Extracting uris from text/uri-list, use the much faster QMimeData method urls()
+        if (mimeData->hasUrls()) {
+            uris = mimeData->urls();
+        }
+    } else {
         // Code from qmimedata.cpp
         QList<QByteArray> urls = ba.split('\n');
         for (int i = 0; i < urls.size(); ++i) {
@@ -85,6 +87,7 @@ QList<QUrl> KUrlMimeData::urlsFromMimeData(const QMimeData *mimeData,
             }
         }
     }
+
     if (metaData) {
         const QByteArray metaDataPayload = mimeData->data(QStringLiteral("application/x-kio-metadata"));
         if (!metaDataPayload.isEmpty()) {
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic