Commit cd507af4 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: CppPreprocessor: Read file only if necessary

Change-Id: Ia60d3e1907f9238f873f016d844095084b76ad6b
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent e2b8ef45
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment