diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-11-11 16:26:04 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-11-18 13:59:41 +0100 |
commit | 3a07c391847b81c7bf40d95fc4d7c49f63073abc (patch) | |
tree | ae481ec0170e6cd53cbd09a28fc780fe0ab467d2 /tests/benchmarks | |
parent | c5f3c61469517a4ac00e4da01fe0bab9188c1488 (diff) | |
download | qtbase-3a07c391847b81c7bf40d95fc4d7c49f63073abc.tar.gz |
Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.
This is a 6.4 re-run of the script we ran in dev, in order to avoid
conflicts between the branches when cherry-picking.
Change-Id: I5eca3df3179dfb2b2682c75a479ba9a4259cc703
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/benchmarks')
6 files changed, 13 insertions, 13 deletions
diff --git a/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp index 95ab82b90a..773f17a35a 100644 --- a/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp +++ b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp @@ -69,7 +69,7 @@ private slots: stack.push(line); line = prefix; - for (const QByteArray &pathElement : qAsConst(stack)) + for (const QByteArray &pathElement : std::as_const(stack)) line += pathElement; if (line.endsWith('/')) diff --git a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp index ea25a3fa98..b7e32be259 100644 --- a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp +++ b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp @@ -508,13 +508,13 @@ void tst_qfile::readSmallFiles() } QBENCHMARK { - for (QFile *const file : qAsConst(fileList)) { + for (QFile *const file : std::as_const(fileList)) { while (!file->atEnd()) file->read(buffer, blockSize); } } - for (QFile *const file : qAsConst(fileList)) { + for (QFile *const file : std::as_const(fileList)) { file->close(); delete file; } @@ -530,11 +530,11 @@ void tst_qfile::readSmallFiles() } QBENCHMARK { - for (QFSFileEngine *const fse : qAsConst(fileList)) + for (QFSFileEngine *const fse : std::as_const(fileList)) while (fse->read(buffer, blockSize)) {} } - for (QFSFileEngine *const fse : qAsConst(fileList)) { + for (QFSFileEngine *const fse : std::as_const(fileList)) { fse->close(); delete fse; } @@ -547,14 +547,14 @@ void tst_qfile::readSmallFiles() fileList.append(::fopen(QFile::encodeName(tempDir.filePath(file)).constData(), "rb")); QBENCHMARK { - for (FILE *const cfile : qAsConst(fileList)) { + for (FILE *const cfile : std::as_const(fileList)) { while (!feof(cfile)) [[maybe_unused]] auto f = ::fread(buffer, blockSize, 1, cfile); ::fseek(cfile, 0, SEEK_SET); } } - for (FILE *const cfile : qAsConst(fileList)) + for (FILE *const cfile : std::as_const(fileList)) ::fclose(cfile); } break; diff --git a/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp b/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp index f6a1a01085..76576fcf69 100644 --- a/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp +++ b/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp @@ -72,7 +72,7 @@ void tst_QSortFilterProxyModel::clearFilter() { QFETCH(const int, itemCount); resizeNumberList(m_numberList, itemCount); - QStringListModel model(qAsConst(m_numberList)); + QStringListModel model(std::as_const(m_numberList)); QCOMPARE(model.rowCount(), itemCount); QSortFilterProxyModel proxy; diff --git a/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp b/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp index 7d047dcd8f..a16299250b 100644 --- a/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp +++ b/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp @@ -81,7 +81,7 @@ void tst_LanceBench::initTestCase() } std::sort(qpsFiles.begin(), qpsFiles.end()); - for (const QString& fileName : qAsConst(qpsFiles)) { + for (const QString& fileName : std::as_const(qpsFiles)) { QFile file(scriptsDir + fileName); file.open(QFile::ReadOnly); QByteArray cont = file.readAll(); @@ -237,7 +237,7 @@ void tst_LanceBench::testCoreOpenGL() void tst_LanceBench::setupTestSuite(const QStringList& blacklist) { QTest::addColumn<QString>("qpsFile"); - for (const QString &fileName : qAsConst(qpsFiles)) { + for (const QString &fileName : std::as_const(qpsFiles)) { if (blacklist.contains(fileName)) continue; QTest::newRow(fileName.toLatin1()) << fileName; diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index 40ef3cdd53..cccf9c703c 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp @@ -670,7 +670,7 @@ void tst_QPainter::drawPixmapImage_data_helper(bool pixmaps) for (; *targetFormats != QImage::Format_Invalid; ++targetFormats) { const QImage::Format *sourceFormats = pixmaps ? pixmapFormats : sourceImageFormats; for (; *sourceFormats != QImage::Format_Invalid; ++sourceFormats) { - for (const QSize &s : qAsConst(sizes)) { + for (const QSize &s : std::as_const(sizes)) { for (int type=0; type<=3; ++type) { QString name = QString::fromLatin1("%1 on %2, (%3x%4), %5") .arg(formatNames[*sourceFormats]) diff --git a/tests/benchmarks/sql/kernel/qsqlrecord/tst_bench_qsqlrecord.cpp b/tests/benchmarks/sql/kernel/qsqlrecord/tst_bench_qsqlrecord.cpp index d1dc3aea19..ae1b92a32c 100644 --- a/tests/benchmarks/sql/kernel/qsqlrecord/tst_bench_qsqlrecord.cpp +++ b/tests/benchmarks/sql/kernel/qsqlrecord/tst_bench_qsqlrecord.cpp @@ -39,7 +39,7 @@ QTEST_MAIN(tst_QSqlRecord) void tst_QSqlRecord::initTestCase() { dbs.open(); - for (const auto &dbName : qAsConst(dbs.dbNames)) { + for (const auto &dbName : std::as_const(dbs.dbNames)) { QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); dropTestTables(db); // In case of leftovers @@ -50,7 +50,7 @@ void tst_QSqlRecord::initTestCase() void tst_QSqlRecord::cleanupTestCase() { - for (const auto &dbName : qAsConst(dbs.dbNames)) { + for (const auto &dbName : std::as_const(dbs.dbNames)) { QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); dropTestTables(db); |