Commit 62a336eb authored by Igor Kushnir's avatar Igor Kushnir

Optimize open-file-only path of ParseProjectJob::queueFilesToParse()

Let the more efficient loop below queue each set element instead of
searching for each open document in the set gradually emptying it.
parent 4a219966
Pipeline #36693 canceled with stage
......@@ -160,20 +160,25 @@ void ParseProjectJob::queueFilesToParse()
}
}
// Add all currently open files that belong to the project to the background-parser, so that they'll be parsed first of all
const auto documents = ICore::self()->documentController()->openDocuments();
for (auto* document : documents) {
const auto path = IndexedString(document->url());
const auto fileIt = d->filesToParse.constFind(path);
if (fileIt != d->filesToParse.cend()) {
ICore::self()->languageController()->backgroundParser()->addDocument(path,
openDocumentProcessingLevel, 10, this);
d->filesToParse.erase(fileIt);
int priority{BackgroundParser::InitialParsePriority};
const int openDocumentPriority{10};
if (d->parseAllProjectSources) {
// Add all currently open files that belong to the project to the
// background-parser, so that they'll be parsed first of all.
const auto documents = ICore::self()->documentController()->openDocuments();
for (auto* document : documents) {
const auto path = IndexedString(document->url());
const auto fileIt = d->filesToParse.constFind(path);
if (fileIt != d->filesToParse.cend()) {
ICore::self()->languageController()->backgroundParser()->addDocument(path,
openDocumentProcessingLevel, openDocumentPriority, this);
d->filesToParse.erase(fileIt);
}
}
}
if (!d->parseAllProjectSources) {
return;
} else {
// In this case the constructor inserts only open documents into d->filesToParse.
processingLevel = openDocumentProcessingLevel;
priority = openDocumentPriority;
}
// prevent UI-lockup by processing events after some files
......@@ -184,7 +189,7 @@ void ParseProjectJob::queueFilesToParse()
auto crashGuard = QPointer<ParseProjectJob> {this};
for (const IndexedString& url : qAsConst(d->filesToParse)) {
ICore::self()->languageController()->backgroundParser()->addDocument(url, processingLevel,
BackgroundParser::InitialParsePriority,
priority,
this);
++processed;
if (processed == processAfter) {
......
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