┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private/kdirectorycontentscounter.cpp
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2020-05-25 15:31:51 +0000
committerMéven Car <[email protected]>2020-05-25 15:31:51 +0000
commitf6afbbc2401cdd2e722e2ea5d3ad59b960370433 (patch)
treecf7410d9c0abc550e76ae4a41d5cdbae5adc4c9f /src/kitemviews/private/kdirectorycontentscounter.cpp
parentb6700f77dd8e07fdab0d40ea4bc91f8d0c03ae70 (diff)
KDirectoryContentsCounter: scan first path not in cache
Use a secondary QLinkedList to store the priority path.
Diffstat (limited to 'src/kitemviews/private/kdirectorycontentscounter.cpp')
-rw-r--r--src/kitemviews/private/kdirectorycontentscounter.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp
index a0ed8c27c..05a6ff447 100644
--- a/src/kitemviews/private/kdirectorycontentscounter.cpp
+++ b/src/kitemviews/private/kdirectorycontentscounter.cpp
@@ -103,7 +103,9 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count, long
m_watchedDirs.insert(resolvedPath);
}
- if (!m_queue.isEmpty()) {
+ if (!m_priorityQueue.isEmpty()) {
+ startWorker(m_priorityQueue.takeLast());
+ } else if (!m_queue.isEmpty()) {
startWorker(m_queue.takeFirst());
}
@@ -167,7 +169,8 @@ void KDirectoryContentsCounter::slotItemsRemoved()
void KDirectoryContentsCounter::startWorker(const QString& path)
{
- if (s_cache->contains(path)) {
+ const bool alreadyInCache = s_cache->contains(path);
+ if (alreadyInCache) {
// fast path when in cache
// will be updated later if result has changed
const auto pair = s_cache->value(path);
@@ -175,8 +178,13 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
}
if (m_workerIsBusy) {
- if (!m_queue.contains(path)) {
- m_queue.append(path);
+ if (!m_queue.contains(path) && !m_priorityQueue.contains(path)) {
+ if (alreadyInCache) {
+ m_queue.append(path);
+ } else {
+ // append to priority queue
+ m_priorityQueue.append(path);
+ }
}
} else {
KDirectoryContentsCounterWorker::Options options;