Xcodebuild parser: Improve performance

QRegExp is extremely ineffecient when capturing everything at the start,
but not matching the end of the expression (e.g. 200+ms when parsing for
signature change message in the relatively long xcodebuild compile
output line).
QRegularExpression is much faster with the same expression (40ms with
the same example), but just checking for "endsWith" and getting the
first part of the line manually is the fastest.

Change-Id: Id5f0378e38f0edeba24036c6e9519c8107e4a361
Task-number: QTCREATORBUG-15613
Reviewed-by: Vikas Pachdha <vikas.pachdha@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2016-04-26 09:34:35 +02:00
committed by Eike Ziller
parent 05ae44dc64
commit 66e9cb0a54
2 changed files with 4 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ namespace ProjectExplorer {
static const char failureRe[] = "\\*\\* BUILD FAILED \\*\\*$";
static const char successRe[] = "\\*\\* BUILD SUCCEEDED \\*\\*$";
static const char buildRe[] = "=== BUILD (AGGREGATE )?TARGET (.*) OF PROJECT (.*) WITH .* ===$";
static const char signatureChangeRe[] = "(.+): replacing existing signature$";
static const char signatureChangeEndsWithPattern[] = ": replacing existing signature";
XcodebuildParser::XcodebuildParser() :
m_fatalErrorCount(0),
@@ -50,8 +50,6 @@ XcodebuildParser::XcodebuildParser() :
QTC_CHECK(m_successRe.isValid());
m_buildRe.setPattern(QLatin1String(buildRe));
QTC_CHECK(m_buildRe.isValid());
m_replacingSignatureRe.setPattern(QLatin1String(signatureChangeRe));
QTC_CHECK(m_replacingSignatureRe.isValid());
}
bool XcodebuildParser::hasFatalErrors() const
@@ -73,11 +71,12 @@ void XcodebuildParser::stdOutput(const QString &line)
m_xcodeBuildParserState = OutsideXcodebuild;
return;
}
if (m_replacingSignatureRe.indexIn(lne) > -1) {
if (lne.endsWith(QLatin1String(signatureChangeEndsWithPattern))) {
Task task(Task::Warning,
QCoreApplication::translate("ProjectExplorer::XcodebuildParser",
"Replacing signature"),
Utils::FileName::fromString(m_replacingSignatureRe.cap(1)), /* filename */
Utils::FileName::fromString(
lne.left(lne.size() - QLatin1String(signatureChangeEndsWithPattern).size())), /* filename */
-1, /* line */
Constants::TASK_CATEGORY_COMPILE);
taskAdded(task, 1);

View File

@@ -55,7 +55,6 @@ private:
QRegExp m_failureRe;
QRegExp m_successRe;
QRegExp m_buildRe;
QRegExp m_replacingSignatureRe;
XcodebuildStatus m_xcodeBuildParserState;
QString m_lastTarget;
QString m_lastProject;