Commit 4a1c479b authored by Anthony Fieroni's avatar Anthony Fieroni
Browse files

[filenamesearch] Fix huge ram usage in kded module


Signed-off-by: Anthony Fieroni's avatarAnthony Fieroni <bvbfan@abv.bg>
parent 9ff08866
...@@ -59,8 +59,13 @@ void FileNameSearchModule::unregisterSearchUrl(const QString &urlString) ...@@ -59,8 +59,13 @@ void FileNameSearchModule::unregisterSearchUrl(const QString &urlString)
void FileNameSearchModule::slotFilesAdded(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) { for (const QUrl &dirUrl : m_searchUrls) {
if (urlString.startsWith(dirUrl.path())) { if (urlPath.startsWith(dirUrl.path())) {
org::kde::KDirNotify::emitFilesAdded(dirUrl); org::kde::KDirNotify::emitFilesAdded(dirUrl);
} }
} }
...@@ -69,11 +74,14 @@ void FileNameSearchModule::slotFilesAdded(const QString &urlString) ...@@ -69,11 +74,14 @@ void FileNameSearchModule::slotFilesAdded(const QString &urlString)
void FileNameSearchModule::slotFilesChanged(const QStringList &files) void FileNameSearchModule::slotFilesChanged(const QStringList &files)
{ {
QList<QUrl> fileList; QList<QUrl> fileList;
fileList.reserve(files.count()); for (const QString &file : files) {
for (const QUrl &dirUrl : m_searchUrls) { QUrl url(file);
for (const QString &file : files) { if (!url.isLocalFile()) {
if (file.startsWith(dirUrl.path())) { continue;
QUrl url(file); }
const QString urlPath = url.path();
for (const QUrl &dirUrl : m_searchUrls) {
if (urlPath.startsWith(dirUrl.path())) {
url.setScheme(QStringLiteral("filenamesearch")); url.setScheme(QStringLiteral("filenamesearch"));
fileList << url; fileList << url;
} }
...@@ -87,11 +95,14 @@ void FileNameSearchModule::slotFilesChanged(const QStringList &files) ...@@ -87,11 +95,14 @@ void FileNameSearchModule::slotFilesChanged(const QStringList &files)
void FileNameSearchModule::slotFilesRemoved(const QStringList &files) void FileNameSearchModule::slotFilesRemoved(const QStringList &files)
{ {
QList<QUrl> fileList; QList<QUrl> fileList;
fileList.reserve(files.count()); for (const QString &file : files) {
for (const QUrl &dirUrl : m_searchUrls) { QUrl url(file);
for (const QString &file : files) { if (!url.isLocalFile()) {
if (file.startsWith(dirUrl.path())) { continue;
QUrl url(file); }
const QString urlPath = url.path();
for (const QUrl &dirUrl : m_searchUrls) {
if (urlPath.startsWith(dirUrl.path())) {
url.setScheme(QStringLiteral("filenamesearch")); url.setScheme(QStringLiteral("filenamesearch"));
fileList << url; fileList << url;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment