forked from qt-creator/qt-creator
Change recursive to loop in allIncludesForDocument
Change-Id: I110294efa506b5a038cfc7f4202fab001e3eefd3 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
#include <cplusplus/TypeVisitor.h>
|
#include <cplusplus/TypeVisitor.h>
|
||||||
#include <cplusplus/CoreTypes.h>
|
#include <cplusplus/CoreTypes.h>
|
||||||
|
|
||||||
|
#include <QStack>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QBitArray>
|
#include <QBitArray>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -834,7 +835,23 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
|
|||||||
QSet<QString> Snapshot::allIncludesForDocument(const QString &fileName) const
|
QSet<QString> Snapshot::allIncludesForDocument(const QString &fileName) const
|
||||||
{
|
{
|
||||||
QSet<QString> result;
|
QSet<QString> result;
|
||||||
allIncludesForDocument_helper(fileName, result);
|
|
||||||
|
QStack<QString> files;
|
||||||
|
files.push(fileName);
|
||||||
|
|
||||||
|
while (!files.isEmpty()) {
|
||||||
|
QString file = files.pop();
|
||||||
|
if (Document::Ptr doc = document(file)) {
|
||||||
|
const QStringList includedFiles = doc->includedFiles();
|
||||||
|
for (const QString &inc : includedFiles) {
|
||||||
|
if (!result.contains(inc)) {
|
||||||
|
result.insert(inc);
|
||||||
|
files.push(inc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,18 +885,6 @@ bool Snapshot::operator==(const Snapshot &other) const
|
|||||||
return _documents == other._documents;
|
return _documents == other._documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snapshot::allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const
|
|
||||||
{
|
|
||||||
if (Document::Ptr doc = document(fileName)) {
|
|
||||||
foreach (const QString &inc, doc->includedFiles()) {
|
|
||||||
if (!result.contains(inc)) {
|
|
||||||
result.insert(inc);
|
|
||||||
allIncludesForDocument_helper(inc, result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Document::Ptr Snapshot::document(const Utils::FilePath &fileName) const
|
Document::Ptr Snapshot::document(const Utils::FilePath &fileName) const
|
||||||
{
|
{
|
||||||
return _documents.value(fileName);
|
return _documents.value(fileName);
|
||||||
|
@@ -450,8 +450,6 @@ public:
|
|||||||
bool operator==(const Snapshot &other) const;
|
bool operator==(const Snapshot &other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const;
|
|
||||||
|
|
||||||
mutable DependencyTable m_deps;
|
mutable DependencyTable m_deps;
|
||||||
Base _documents;
|
Base _documents;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user