From 5b54d59d23ceccb5f063046675a1b2af6b1bc9f2 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 24 Feb 2009 11:49:01 +0100 Subject: [PATCH] Cleanup the indexer, and remove to old sequential stuff. --- src/plugins/cpptools/cppmodelmanager.cpp | 49 ++++++++---------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 586ea67c0e2..b8ab636dbd9 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -173,10 +173,11 @@ public: void setTodo(const QStringList &files); void run(const QString &fileName); - void run_helper(const QString &fileName, QList *documents); void resetEnvironment(); + void parseCollectedDocuments(); + const QSet &todo() const { return m_todo; } @@ -214,7 +215,7 @@ private: QSet m_included; Document::Ptr m_currentDoc; QSet m_todo; - QList *m_documents; + QList m_documents; }; } // namespace Internal @@ -223,8 +224,7 @@ private: CppPreprocessor::CppPreprocessor(QPointer modelManager) : snapshot(modelManager->snapshot()), m_modelManager(modelManager), - m_proc(this, env), - m_documents(0) + m_proc(this, env) { } void CppPreprocessor::setWorkingCopy(const QMap &workingCopy) @@ -267,45 +267,24 @@ public: } // end of anonymous namespace -// #define QTCREATOR_WITH_PARALLEL_INDEXER - void CppPreprocessor::run(const QString &fileName) { - QList documents; - run_helper(fileName, &documents); - -#ifdef QTCREATOR_WITH_PARALLEL_INDEXER - QFuture future = QtConcurrent::map(documents, Process(m_modelManager)); - future.waitForFinished(); - -#else - foreach (Document::Ptr doc, documents) { - doc->parse(); - doc->check(); - - doc->releaseTranslationUnit(); - - if (m_modelManager) - m_modelManager->emitDocumentUpdated(doc); // ### TODO: compress - } -#endif -} - -void CppPreprocessor::run_helper(const QString &fileName, - QList *documents) -{ - QList *previousDocuments = m_documents; - m_documents = documents; - QString absoluteFilePath = fileName; sourceNeeded(absoluteFilePath, IncludeGlobal, /*line = */ 0); - m_documents = previousDocuments; + if (m_documents.size() >= 8) + parseCollectedDocuments(); } void CppPreprocessor::resetEnvironment() { env.reset(); } +void CppPreprocessor::parseCollectedDocuments() +{ + QtConcurrent::blockingMap(m_documents, Process(m_modelManager)); + m_documents.clear(); +} + bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QByteArray *result) { if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) { @@ -538,7 +517,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, snapshot.insert(doc->fileName(), doc); - m_documents->append(doc); + m_documents.append(doc); (void) switchDocument(previousDoc); @@ -1020,6 +999,8 @@ void CppModelManager::parse(QFutureInterface &future, #endif } + preproc->parseCollectedDocuments(); + future.setProgressValue(files.size()); // Restore the previous thread priority.