Commit 77a61d2a authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

avoid creation of file list if no index will be generated, that is the default

parent 555e8284
......@@ -45,14 +45,48 @@ void KateProjectWorker::run()
*/
topLevel->sortChildren(0);
/**
* decide if we need to create an index
* if we need to do so, we will need to create a copy of the file list for later use
* before this was default on, which is dangerous for large repositories, e.g. out-of-memory or out-of-disk
* if specified in project map; use that setting, otherwise fall back to global setting
*/
bool indexEnabled = !m_indexDir.isEmpty();
const QVariantMap ctagsMap = m_projectMap[QStringLiteral("ctags")].toMap();
auto indexValue = ctagsMap[QStringLiteral("enable")];
if (!indexValue.isNull()) {
indexEnabled = indexValue.toBool();
}
/**
* create some local backup of some data we need for further processing!
* this is expensive, therefore only really do this if required!
*/
QStringList files;
if (indexEnabled) {
files = file2Item->keys();
}
/**
* hand out our model item & mapping to the main thread
* that will let Kate already show the project, even before index processing starts
*/
const QStringList files = file2Item->keys();
Q_EMIT loadDone(topLevel, file2Item);
// trigger index loading, will internally handle enable/disabled
loadIndex(files, m_force);
/**
* without indexing, we are even done with all stuff here
*/
if (!indexEnabled) {
Q_EMIT loadIndexDone(KateProjectSharedProjectIndex());
return;
}
/**
* create new index, this will do the loading in the constructor
* wrap it into shared pointer for transfer to main thread
*/
KateProjectSharedProjectIndex index(new KateProjectIndex(m_baseDir, m_indexDir, files, ctagsMap, m_force));
Q_EMIT loadIndexDone(index);
}
void KateProjectWorker::loadProject(QStandardItem *parent, const QVariantMap &project, QHash<QString, KateProjectItem *> *file2Item)
......@@ -509,31 +543,3 @@ QStringList KateProjectWorker::filesFromDirectory(const QDir &_dir, bool recursi
}
return files;
}
void KateProjectWorker::loadIndex(const QStringList &files, bool force)
{
const QString keyCtags = QStringLiteral("ctags");
const QVariantMap ctagsMap = m_projectMap[keyCtags].toMap();
/**
* load index, if enabled
* before this was default on, which is dangerous for large repositories, e.g. out-of-memory or out-of-disk
* if specified in project map; use that setting, otherwise fall back to global setting
*/
bool indexEnabled = !m_indexDir.isEmpty();
auto indexValue = ctagsMap[QStringLiteral("enable")];
if (!indexValue.isNull()) {
indexEnabled = indexValue.toBool();
}
if (!indexEnabled) {
emit loadIndexDone(KateProjectSharedProjectIndex());
return;
}
/**
* create new index, this will do the loading in the constructor
* wrap it into shared pointer for transfer to main thread
*/
KateProjectSharedProjectIndex index(new KateProjectIndex(m_baseDir, m_indexDir, files, ctagsMap, force));
emit loadIndexDone(index);
}
......@@ -57,12 +57,6 @@ private:
*/
void loadFilesEntry(QStandardItem *parent, const QVariantMap &filesEntry, QHash<QString, KateProjectItem *> *file2Item);
/**
* Load index for whole project.
* @param files list of all project files to index
*/
void loadIndex(const QStringList &files, bool force);
QStringList findFiles(const QDir &dir, const QVariantMap &filesEntry);
QStringList filesFromGit(const QDir &dir, bool recursive);
......
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