aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@digia.com>2014-03-05 16:58:19 -0300
committerNikolai Kosjar <nikolai.kosjar@digia.com>2014-03-10 17:36:43 +0100
commitcd507af47632f453d918870c633044c275b81635 (patch)
treea09da6f3af91fa300c98cd023ddeb3eb98a3911a /src/plugins/cpptools
parente2b8ef4592c925aec9b86993a8eebd567aba3410 (diff)
CppTools: CppPreprocessor: Read file only if necessary
Change-Id: Ia60d3e1907f9238f873f016d844095084b76ad6b Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cpppreprocessor.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/plugins/cpptools/cpppreprocessor.cpp b/src/plugins/cpptools/cpppreprocessor.cpp
index b2768850013..7bc50c5f9e9 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);