Commit e59b5d72 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

use map not filter for concurrency

the difference in locking makes a factor in speed
for e.g. 32 threads

filter is by factor 6 slower than map
parent f7519ea9
......@@ -17,7 +17,7 @@
#include <QSettings>
#include <QThread>
#include <QTime>
#include <QtConcurrentFilter>
#include <QtConcurrent>
#include <algorithm>
......@@ -285,27 +285,28 @@ void KateProjectWorker::loadFilesEntry(QStandardItem *parent, const QVariantMap
* sort out non-files
* even for git, that just reports non-directories, we need to filter out e.g. sym-links to directories
* we use map, not filter, less locking!
* we invalidate not matching stuff by clearing the string and skip that then below in processing
const QString dirPath = dir.path() + QLatin1Char('/');
QtConcurrent::blockingFilter(files, [dirPath](const QString &item) {
return QFileInfo(dirPath + item).isFile();
* we might end up with nothing to add at all
if (files.isEmpty()) {
QtConcurrent::blockingMap(files, [dirPath](QString &item) {
if (!QFileInfo(dirPath + item).isFile()) {
* construct paths first in tree and items in a map
QHash<QString, QStandardItem *> dir2Item;
dir2Item[QString()] = parent;
file2Item->reserve(files.size()); // perhaps a bit too much, as we emptied stuff above, but who cares!
for (const QString &filePath : qAsConst(files)) {
// skip empty files, that is filtered stuff
if (filePath.isEmpty()) {
* cheap file name computation
* we do this A LOT, QFileInfo is very expensive just for this operation
Supports Markdown
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