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 <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Samuel Gaist 2018-08-27 00:16:58 +02:00
parent 8374b4016e
commit ffc71a977f
1 changed files with 9 additions and 9 deletions

View File

@ -46,6 +46,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qprocess.h>
#include <QtCore/qdir.h>
#include <QtCore/qregularexpression.h>
#include <QtCore/qset.h>
#include <QtTest/private/callgrind_p.h>
@ -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) {