summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppsourceprocessor.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2023-05-02 17:55:44 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2023-05-03 09:50:53 +0000
commita03bea81c7bb994367855ab40b9d76e974bbff50 (patch)
tree2a8484d47a6d1f148855971086df91a7366b20c5 /src/plugins/cppeditor/cppsourceprocessor.cpp
parente15b38494433a6f3e608f561517966ea0d745ddf (diff)
downloadqt-creator-a03bea81c7bb994367855ab40b9d76e974bbff50.tar.gz
CppEditor: Remove WorkingCopy::contains()
Most uses involved a double look-up. Change-Id: Ifeb62ea2361222ed0faad749f44a59735c8d6930 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppsourceprocessor.cpp')
-rw-r--r--src/plugins/cppeditor/cppsourceprocessor.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/cppeditor/cppsourceprocessor.cpp b/src/plugins/cppeditor/cppsourceprocessor.cpp
index 66cca58a0f..55dc1f10e0 100644
--- a/src/plugins/cppeditor/cppsourceprocessor.cpp
+++ b/src/plugins/cppeditor/cppsourceprocessor.cpp
@@ -81,7 +81,8 @@ inline const CPlusPlus::Macro revision(const WorkingCopy &workingCopy,
const CPlusPlus::Macro &macro)
{
CPlusPlus::Macro newMacro(macro);
- newMacro.setFileRevision(workingCopy.get(macro.filePath()).second);
+ if (const auto entry = workingCopy.get(macro.filePath()))
+ newMacro.setFileRevision(entry->second);
return newMacro;
}
@@ -189,10 +190,9 @@ bool CppSourceProcessor::getFileContents(const FilePath &absoluteFilePath,
return false;
// Get from working copy
- if (m_workingCopy.contains(absoluteFilePath)) {
- const QPair<QByteArray, unsigned> entry = m_workingCopy.get(absoluteFilePath);
- *contents = entry.first;
- *revision = entry.second;
+ if (const auto entry = m_workingCopy.get(absoluteFilePath)) {
+ *contents = entry->first;
+ *revision = entry->second;
return true;
}
@@ -216,7 +216,7 @@ bool CppSourceProcessor::checkFile(const FilePath &absoluteFilePath) const
{
if (absoluteFilePath.isEmpty()
|| m_included.contains(absoluteFilePath)
- || m_workingCopy.contains(absoluteFilePath)) {
+ || m_workingCopy.get(absoluteFilePath)) {
return true;
}
@@ -281,7 +281,7 @@ FilePath CppSourceProcessor::resolveFile_helper(const FilePath &filePath,
} else {
path = FilePath::fromString(headerPathsIt->path) / fileName;
}
- if (m_workingCopy.contains(path) || checkFile(path))
+ if (m_workingCopy.get(path) || checkFile(path))
return path;
}
}
@@ -468,8 +468,8 @@ void CppSourceProcessor::sourceNeeded(int line, const FilePath &filePath, Includ
document->setUtf8Source(preprocessedCode);
document->keepSourceAndAST();
document->tokenize();
- document->check(m_workingCopy.contains(document->filePath()) ? Document::FullCheck
- : Document::FastCheck);
+ document->check(m_workingCopy.get(document->filePath()) ? Document::FullCheck
+ : Document::FastCheck);
m_documentFinished(document);