From aa37e67ef7f5ff22da0ef95fb5221bc1fff9b3ca Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2022 11:08:21 +0200 Subject: 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, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev --- .../benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp | 2 +- tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp | 12 ++++++------ .../tst_bench_qsortfilterproxymodel.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/benchmarks/corelib') 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; -- cgit v1.2.3