make QMakeParser take a QStringRef as input

the only place where this actually saves a deep copy is the evaluation
of if(), but as a side effect the parser is now able to deal with not
null-terminated strings, which is kinda nice as well.

Change-Id: Ib6d08617aa79d2f9eaecd4906d4d548f34bf377d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
(cherry picked from qtbase/ad17a35853fe21a93fc34f7b2d9262c5ac992b29)
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Oswald Buddenhagen
2016-05-13 15:32:50 +02:00
parent 50b87b3a8d
commit b7706cdfeb
7 changed files with 33 additions and 29 deletions

View File

@@ -1229,7 +1229,7 @@ QPair<ProFile *, QStringList> QmakePriFileNode::readProFile(const QString &file)
QMakeVfs vfs;
QtSupport::ProMessageHandler handler;
QMakeParser parser(0, &vfs, &handler);
includeFile = parser.parsedProBlock(contents, file, 1);
includeFile = parser.parsedProBlock(QStringRef(&contents), file, 1);
}
return qMakePair(includeFile, lines);
}
@@ -1264,7 +1264,8 @@ bool QmakePriFileNode::renameFile(const QString &oldName,
// We need to re-parse here: The file has changed.
QMakeParser parser(0, 0, 0);
includeFile = parser.parsedProBlock(lines.join(QLatin1Char('\n')),
QString contents = lines.join(QLatin1Char('\n'));
includeFile = parser.parsedProBlock(QStringRef(&contents),
m_projectFilePath.toString(), 1, QMakeParser::FullGrammar);
QTC_ASSERT(includeFile, return false); // The file should still be valid after what we did.