diff options
| author | Samuel Gaist <[email protected]> | 2018-08-27 00:16:58 +0200 | 
|---|---|---|
| committer | Samuel Gaist <[email protected]> | 2019-04-09 06:57:46 +0000 | 
| commit | ffc71a977f4bef2872c5c93ddd4db7ebaee8e356 (patch) | |
| tree | 3f85f7b3d0db33e1fa505af284afa250e61a2bf5 /src/testlib/qbenchmarkvalgrind.cpp | |
| parent | 8374b4016e730992ce72e69f81f183c518fdfe2c (diff) | |
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 <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/testlib/qbenchmarkvalgrind.cpp')
| -rw-r--r-- | src/testlib/qbenchmarkvalgrind.cpp | 18 | 
1 files changed, 9 insertions, 9 deletions
diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index 1de149258d5..7d24eb8293c 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -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) {  | 
