CppTools: CppPreprocessor: Read file only if necessary

Change-Id: Ia60d3e1907f9238f873f016d844095084b76ad6b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-03-05 16:58:19 -03:00
parent e2b8ef4592
commit cd507af476

View File

@@ -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);