From a03bea81c7bb994367855ab40b9d76e974bbff50 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 2 May 2023 17:55:44 +0200 Subject: CppEditor: Remove WorkingCopy::contains() Most uses involved a double look-up. Change-Id: Ifeb62ea2361222ed0faad749f44a59735c8d6930 Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppsourceprocessor.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/plugins/cppeditor/cppsourceprocessor.cpp') 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 ¯o) { 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 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); -- cgit v1.2.1