forked from qt-creator/qt-creator
CppTools: CppPreprocessor: Read file only if necessary
Change-Id: Ia60d3e1907f9238f873f016d844095084b76ad6b Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user