From ffc71a977f4bef2872c5c93ddd4db7ebaee8e356 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 27 Aug 2018 00:16:58 +0200 Subject: [PATCH] QBenchmarkValgrindUtils: port to QRegularExpression This patch updates the code from the deprecated QRegExp class to QRegularExpression. Task-number: QTBUG-25485 Change-Id: I946790f50c6b14787bca31771de5e3a0d5fefe4c Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/testlib/qbenchmarkvalgrind.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index 1de149258d..7d24eb8293 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -90,13 +91,13 @@ qint64 QBenchmarkValgrindUtils::extractResult(const QString &fileName) qint64 val = -1; bool valSeen = false; - QRegExp rxValue(QLatin1String("^summary: (\\d+)")); + QRegularExpression rxValue(QLatin1String("^summary: (\\d+)")); while (!file.atEnd()) { const QString line(QLatin1String(file.readLine())); - if (rxValue.indexIn(line) != -1) { - Q_ASSERT(rxValue.captureCount() == 1); + QRegularExpressionMatch match = rxValue.match(line); + if (match.hasMatch()) { bool ok; - val = rxValue.cap(1).toLongLong(&ok); + val = match.captured(1).toLongLong(&ok); Q_ASSERT(ok); valSeen = true; break; @@ -120,13 +121,12 @@ QString QBenchmarkValgrindUtils::getNewestFileName() int hiSuffix = -1; QFileInfo lastFileInfo; const QString pattern = QString::fromLatin1("%1.(\\d+)").arg(base); - QRegExp rx(pattern); + QRegularExpression rx(pattern); for (const QFileInfo &fileInfo : fiList) { - const int index = rx.indexIn(fileInfo.fileName()); - Q_ASSERT(index == 0); - Q_UNUSED(index); + QRegularExpressionMatch match = rx.match(fileInfo.fileName()); + Q_ASSERT(match.hasMatch()); bool ok; - const int suffix = rx.cap(1).toInt(&ok); + const int suffix = match.captured(1).toInt(&ok); Q_ASSERT(ok); Q_ASSERT(suffix >= 0); if (suffix > hiSuffix) {