summaryrefslogtreecommitdiff
path: root/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-03-21 17:55:24 +0100
committerMarco Bubke <marco.bubke@qt.io>2019-04-02 13:08:44 +0000
commit56b01f74633c310807cf3fc00766cfa01002297f (patch)
treea8e0a09154f4c95dd8b16db2a8512c2f5b5b0946 /src/tools/clangrefactoringbackend/source/symbolindexer.cpp
parent7595c9f3052cf7c2ca05f3157c945371952ca0b5 (diff)
downloadqt-creator-56b01f74633c310807cf3fc00766cfa01002297f.tar.gz
Clang: Minimize reindexing
We optimal indexer is only reindexing if the index would be changed. This patch is a step in that direction. We only reindex now if the file or project has changed. It fixes some typos too. Task-number: QTCREATORBUG-21150 Change-Id: I6ea1c13282fbcd70253b9b2939aed37580dbd160 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolindexer.cpp')
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexer.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
index e21268322a..6d0978e54a 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
+++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
@@ -66,7 +66,8 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
FilePathCachingInterface &filePathCache,
FileStatusCache &fileStatusCache,
Sqlite::TransactionInterface &transactionInterface,
- ProjectPartsStorageInterface &projectPartsStorage)
+ ProjectPartsStorageInterface &projectPartsStorage,
+ ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker)
: m_symbolIndexerTaskQueue(symbolIndexerTaskQueue)
, m_symbolStorage(symbolStorage)
, m_buildDependencyStorage(buildDependenciesStorage)
@@ -76,6 +77,7 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
, m_fileStatusCache(fileStatusCache)
, m_transactionInterface(transactionInterface)
, m_projectPartsStorage(projectPartsStorage)
+ , m_modifiedTimeChecker(modifiedTimeChecker)
{
pathWatcher.setNotifier(this);
}
@@ -109,23 +111,27 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
std::vector<SymbolIndexerTask> symbolIndexerTask;
symbolIndexerTask.reserve(projectPart.sourcePathIds.size());
for (FilePathId sourcePathId : projectPart.sourcePathIds) {
- auto indexing = [arguments = commandLineBuilder.commandLine,
- sourcePathId,
- this](SymbolsCollectorInterface &symbolsCollector) {
- symbolsCollector.setFile(sourcePathId, arguments);
-
- bool success = symbolsCollector.collectSymbols();
-
- if (success) {
- Sqlite::ImmediateTransaction transaction{m_transactionInterface};
-
- m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
- symbolsCollector.sourceLocations());
- transaction.commit();
- }
- };
-
- symbolIndexerTask.emplace_back(sourcePathId, projectPartId, std::move(indexing));
+ SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(
+ sourcePathId);
+
+ if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) {
+ auto indexing = [arguments = commandLineBuilder.commandLine, sourcePathId, this](
+ SymbolsCollectorInterface &symbolsCollector) {
+ symbolsCollector.setFile(sourcePathId, arguments);
+
+ bool success = symbolsCollector.collectSymbols();
+
+ if (success) {
+ Sqlite::ImmediateTransaction transaction{m_transactionInterface};
+ m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
+ m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
+ symbolsCollector.sourceLocations());
+ transaction.commit();
+ }
+ };
+
+ symbolIndexerTask.emplace_back(sourcePathId, projectPartId, std::move(indexing));
+ }
}
m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask));
@@ -136,11 +142,13 @@ void SymbolIndexer::pathsWithIdsChanged(const ProjectPartIds &) {}
void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds)
{
+ FilePathIds dependentSourcePathIds = m_symbolStorage.fetchDependentSourceIds(filePathIds);
+
std::vector<SymbolIndexerTask> symbolIndexerTask;
- symbolIndexerTask.reserve(filePathIds.size());
+ symbolIndexerTask.reserve(dependentSourcePathIds.size());
- for (FilePathId filePathId : filePathIds)
- updateChangedPath(filePathId, symbolIndexerTask);
+ for (FilePathId dependentSourcePathId : dependentSourcePathIds)
+ updateChangedPath(dependentSourcePathId, symbolIndexerTask);
m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask));
m_symbolIndexerTaskQueue.processEntries();
@@ -161,6 +169,8 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
= m_precompiledHeaderStorage.fetchPrecompiledHeader(optionalArtefact->projectPartId);
transaction.commit();
+ SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(filePathId);
+
const ProjectPartArtefact &artefact = *optionalArtefact;
auto pchPath = optionalProjectPartPch ? optionalProjectPartPch->pchPath : FilePath{};
@@ -176,10 +186,9 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
if (success) {
Sqlite::ImmediateTransaction transaction{m_transactionInterface};
-
+ m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
symbolsCollector.sourceLocations());
-
transaction.commit();
}
};