m_watchedDirs.insert(resolvedPath);
}
- if (!m_queue.isEmpty()) {
- startWorker(m_queue.dequeue());
+ if (!m_priorityQueue.empty()) {
+ const QString firstPath = m_priorityQueue.front();
+ m_priorityQueue.pop_front();
+ startWorker(firstPath);
+ } else if (!m_queue.empty()) {
+ const QString firstPath = m_queue.front();
+ m_queue.pop_front();
+ startWorker(firstPath);
}
if (s_cache->contains(resolvedPath)) {
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);
}
if (m_workerIsBusy) {
- m_queue.enqueue(path);
+ if (std::find(m_queue.begin(), m_queue.end(), path) == m_queue.end() &&
+ std::find(m_priorityQueue.begin(), m_priorityQueue.end(), path) == m_priorityQueue.end()) {
+ if (alreadyInCache) {
+ m_queue.push_back(path);
+ } else {
+ // append to priority queue
+ m_priorityQueue.push_back(path);
+ }
+ }
} else {
KDirectoryContentsCounterWorker::Options options;