diff options
author | Nicolas Arnaud-Cormos <nicolas@kdab.com> | 2012-01-08 16:00:32 +0100 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2012-01-11 11:47:54 +0100 |
commit | 4095b807938778b4a8f2f41785461fc6eff30111 (patch) | |
tree | 629bf6a451ae90b9106d021701ae1c964302da36 /src/plugins/cpptools/cpptoolsplugin.cpp | |
parent | ab8d39ace139881b1b6cd02c3d7b8e318ebc5e2c (diff) | |
download | qt-creator-4095b807938778b4a8f2f41785461fc6eff30111.tar.gz |
Add a cache for the header/source mapping.
Now that we are iterating all the files in the project (instead of stopping at
the first success), we need a cache to make the switching fast enough on big
projects.
Change-Id: Ib7d63c93b3303c534ca53856d96333a822046ced
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r-- | src/plugins/cpptools/cpptoolsplugin.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 2ae47b1143..c08b639e47 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -261,13 +261,16 @@ static int commonStringLength(const QString &s1, const QString &s2) QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) const { + const QFileInfo fi(fileName); + if (m_headerSourceMapping.contains(fi.absoluteFilePath())) + return m_headerSourceMapping.value(fi.absoluteFilePath()); + const Core::ICore *core = Core::ICore::instance(); const Core::MimeDatabase *mimeDatase = core->mimeDatabase(); ProjectExplorer::ProjectExplorerPlugin *explorer = ProjectExplorer::ProjectExplorerPlugin::instance(); ProjectExplorer::Project *project = (explorer ? explorer->currentProject() : 0); - const QFileInfo fi(fileName); const FileType type = fileType(mimeDatase, fi); if (debug) @@ -298,8 +301,11 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co // Try to find a file in the same directory first foreach (const QString &candidateFileName, candidateFileNames) { const QFileInfo candidateFi(absoluteDir, candidateFileName); - if (candidateFi.isFile()) + if (candidateFi.isFile()) { + m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath(); + m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath(); return candidateFi.absoluteFilePath(); + } } // Find files in the project @@ -320,6 +326,8 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co if (!bestFileName.isEmpty()) { const QFileInfo candidateFi(bestFileName); Q_ASSERT(candidateFi.isFile()); + m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath(); + m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath(); return candidateFi.absoluteFilePath(); } } |