From c98a390733fbb05db602543e73de2ff24e9f4683 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Jul 2018 15:27:24 +0200 Subject: [PATCH] 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 Reviewed-by: Eike Ziller --- src/libs/utils/fileinprojectfinder.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libs/utils/fileinprojectfinder.cpp b/src/libs/utils/fileinprojectfinder.cpp index f7324176797..026ff20d59f 100644 --- a/src/libs/utils/fileinprojectfinder.cpp +++ b/src/libs/utils/fileinprojectfinder.cpp @@ -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)) {