From cd507af47632f453d918870c633044c275b81635 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 5 Mar 2014 16:58:19 -0300 Subject: CppTools: CppPreprocessor: Read file only if necessary Change-Id: Ia60d3e1907f9238f873f016d844095084b76ad6b Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cpppreprocessor.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/plugins/cpptools/cpppreprocessor.cpp') diff --git a/src/plugins/cpptools/cpppreprocessor.cpp b/src/plugins/cpptools/cpppreprocessor.cpp index b276885001..7bc50c5f9e 100644 --- a/src/plugins/cpptools/cpppreprocessor.cpp +++ b/src/plugins/cpptools/cpppreprocessor.cpp @@ -410,6 +410,14 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu if (absoluteFileName != modelManager()->configurationFileName()) m_included.insert(absoluteFileName); + // Already in snapshot? Use it! + Document::Ptr doc = m_snapshot.document(absoluteFileName); + if (doc) { + mergeEnvironment(doc); + return; + } + + // Otherwise get file contents unsigned editorRevision = 0; QByteArray contents; const bool gotFileContents = getFileContents(absoluteFileName, &contents, &editorRevision); @@ -427,12 +435,6 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu << "contents:" << contents.size() << "bytes"; } - Document::Ptr doc = m_snapshot.document(absoluteFileName); - if (doc) { - mergeEnvironment(doc); - return; - } - doc = Document::create(absoluteFileName); doc->setRevision(m_revision); doc->setEditorRevision(editorRevision); -- cgit v1.2.1