Store path as FilePath instead of QString

This avoids conversions from FilePath to QString and
vice versa.

Change-Id: Ic0f610a9e90c206ff9557df6f46854e4805ce42f
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2020-12-17 12:33:18 +01:00
parent c732014821
commit 4654550ff4
2 changed files with 7 additions and 12 deletions

View File

@@ -151,19 +151,14 @@ TypeHierarchy TypeHierarchyBuilder::buildDerivedTypeHierarchy(QFutureInterfaceBa
return hierarchy; return hierarchy;
} }
static QStringList filesDependingOn(const CPlusPlus::Snapshot &snapshot, static Utils::FilePaths filesDependingOn(const CPlusPlus::Snapshot &snapshot,
CPlusPlus::Symbol *symbol) CPlusPlus::Symbol *symbol)
{ {
QStringList deps;
if (!symbol) if (!symbol)
return deps; return Utils::FilePaths();
const Utils::FilePath file = Utils::FilePath::fromUtf8(symbol->fileName(), symbol->fileNameLength()); const Utils::FilePath file = Utils::FilePath::fromUtf8(symbol->fileName(), symbol->fileNameLength());
deps << file.toString(); return Utils::FilePaths { file } + snapshot.filesDependingOn(file);
const Utils::FilePaths filePaths = snapshot.filesDependingOn(file);
for (const Utils::FilePath &fileName : filePaths)
deps.append(fileName.toString());
return deps;
} }
void TypeHierarchyBuilder::buildDerived(QFutureInterfaceBase &futureInterface, void TypeHierarchyBuilder::buildDerived(QFutureInterfaceBase &futureInterface,
@@ -180,12 +175,12 @@ void TypeHierarchyBuilder::buildDerived(QFutureInterfaceBase &futureInterface,
const QString &symbolName = _overview.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(symbol)); const QString &symbolName = _overview.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(symbol));
DerivedHierarchyVisitor visitor(symbolName); DerivedHierarchyVisitor visitor(symbolName);
const QStringList &dependingFiles = filesDependingOn(snapshot, symbol); const Utils::FilePaths &dependingFiles = filesDependingOn(snapshot, symbol);
if (depth == 0) if (depth == 0)
futureInterface.setProgressRange(0, dependingFiles.size()); futureInterface.setProgressRange(0, dependingFiles.size());
int i = -1; int i = -1;
for (const QString &fileName : dependingFiles) { for (const Utils::FilePath &fileName : dependingFiles) {
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
if (depth == 0) if (depth == 0)

View File

@@ -70,7 +70,7 @@ private:
const CPlusPlus::Snapshot &snapshot, int depth = 0); const CPlusPlus::Snapshot &snapshot, int depth = 0);
QSet<CPlusPlus::Symbol *> _visited; QSet<CPlusPlus::Symbol *> _visited;
QHash<QString, QSet<QString> > _candidates; QHash<Utils::FilePath, QSet<QString> > _candidates;
CPlusPlus::Overview _overview; CPlusPlus::Overview _overview;
}; };