FileInProjectFinder: Use the cache also without project directory

As we add things to the cache, also without a project directory, there
is no reason why we wouldn't use the cache when looking them up.

Change-Id: I9f90cf7b88410513d2ebd0524e7d369fcb4db704
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Ulf Hermann
2018-07-25 15:27:24 +02:00
parent d35638df56
commit c98a390733

View File

@@ -159,22 +159,22 @@ QString FileInProjectFinder::findFileOrDirectory(const QString &originalPath, Fi
return originalPath;
}
auto it = m_cache.find(originalPath);
if (it != m_cache.end()) {
if (debug)
qDebug() << "FileInProjectFinder: checking cache ...";
// check if cached path is still there
const QString &candidate = it.value();
if (checkPath(candidate, findMode))
return handleSuccess(originalPath, candidate, success, "in the cache", false);
else
m_cache.erase(it);
}
if (!m_projectDir.isEmpty()) {
if (debug)
qDebug() << "FileInProjectFinder: checking project directory ...";
auto it = m_cache.find(originalPath);
if (it != m_cache.end()) {
if (debug)
qDebug() << "FileInProjectFinder: checking cache ...";
// check if cached path is still there
const QString &candidate = it.value();
if (checkPath(candidate, findMode))
return handleSuccess(originalPath, candidate, success, "in the cache", false);
else
m_cache.erase(it);
}
int prefixToIgnore = -1;
const QChar separator = QLatin1Char('/');
if (originalPath.startsWith(m_projectDir + separator)) {