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

List:       kde-commits
Subject:    [kio-extras/Applications/16.08] filenamesearch/kded: [filenamesearch] Fix huge ram usage in kded mod
From:       Anthony Fieroni <bvbfan () abv ! bg>
Date:       2016-12-04 18:52:55
Message-ID: E1cDbuB-00024d-AR () code ! kde ! org
[Download RAW message or body]

Git commit 2a52c482698f2774b2ea8d6906c0246f6865d9ac by Anthony Fieroni.
Committed on 04/12/2016 at 18:50.
Pushed by anthonyfieroni into branch 'Applications/16.08'.

[filenamesearch] Fix huge ram usage in kded module

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>

M  +22   -11   filenamesearch/kded/filenamesearchmodule.cpp

https://commits.kde.org/kio-extras/2a52c482698f2774b2ea8d6906c0246f6865d9ac

diff --git a/filenamesearch/kded/filenamesearchmodule.cpp b/filenamesearch/kded/filenamesearchmodule.cpp
index 3f9f582..f12626d 100644
--- a/filenamesearch/kded/filenamesearchmodule.cpp
+++ b/filenamesearch/kded/filenamesearchmodule.cpp
@@ -59,8 +59,13 @@ void FileNameSearchModule::unregisterSearchUrl(const QString &urlString)
 
 void FileNameSearchModule::slotFilesAdded(const QString &urlString)
 {
+    const QUrl url(urlString);
+    if (!url.isLocalFile()) {
+        return;
+    }
+    const QString urlPath = url.path();
     for (const QUrl &dirUrl : m_searchUrls) {
-        if (urlString.startsWith(dirUrl.path())) {
+        if (urlPath.startsWith(dirUrl.path())) {
             org::kde::KDirNotify::emitFilesAdded(dirUrl);
         }
     }
@@ -69,11 +74,14 @@ void FileNameSearchModule::slotFilesAdded(const QString &urlString)
 void FileNameSearchModule::slotFilesChanged(const QStringList &files)
 {
     QList<QUrl> fileList;
-    fileList.reserve(files.count());
-    for (const QUrl &dirUrl : m_searchUrls) {
-        for (const QString &file : files) {
-            if (file.startsWith(dirUrl.path())) {
-                QUrl url(file);
+    for (const QString &file : files) {
+        QUrl url(file);
+        if (!url.isLocalFile()) {
+            continue;
+        }
+        const QString urlPath = url.path();
+        for (const QUrl &dirUrl : m_searchUrls) {
+            if (urlPath.startsWith(dirUrl.path())) {
                 url.setScheme(QStringLiteral("filenamesearch"));
                 fileList << url;
             }
@@ -87,11 +95,14 @@ void FileNameSearchModule::slotFilesChanged(const QStringList &files)
 void FileNameSearchModule::slotFilesRemoved(const QStringList &files)
 {
     QList<QUrl> fileList;
-    fileList.reserve(files.count());
-    for (const QUrl &dirUrl : m_searchUrls) {
-        for (const QString &file : files) {
-            if (file.startsWith(dirUrl.path())) {
-                QUrl url(file);
+    for (const QString &file : files) {
+        QUrl url(file);
+        if (!url.isLocalFile()) {
+            continue;
+        }
+        const QString urlPath = url.path();
+        for (const QUrl &dirUrl : m_searchUrls) {
+            if (urlPath.startsWith(dirUrl.path())) {
                 url.setScheme(QStringLiteral("filenamesearch"));
                 fileList << url;
             }
[prev in list] [next in list] [prev in thread] [next in thread] 

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