From 39c96faa2ce39568d878d424735815fc8bed3e47 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 3 Aug 2023 21:32:05 +0200 Subject: [PATCH] Eradicate the last Q_FOREACHs and mark the module free of them ... again Restores the QT_NO_FOREACH define lost by the removal of .qmake.conf in 21136bf84c33a6a618c776ea4cd67d0c30d027c7. The instances in the big5 utility are all over local variables, and they clearly don't modify the container being iterateed over. Add std::as_const() to avoid hidden detach()es. Replace two loops with QByteArrayList::join(). Change-Id: If01bc667f019da0dbce99d84db5832067c5d936d Reviewed-by: Ivan Solovev --- .cmake.conf | 1 + util/unicode/codecs/big5/main.cpp | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.cmake.conf b/.cmake.conf index d2a745a..015c6ca 100644 --- a/.cmake.conf +++ b/.cmake.conf @@ -2,3 +2,4 @@ set(QT_REPO_MODULE_VERSION "6.7.0") set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1") set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1") list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1") +list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1") diff --git a/util/unicode/codecs/big5/main.cpp b/util/unicode/codecs/big5/main.cpp index 4c4677c..6d3146f 100644 --- a/util/unicode/codecs/big5/main.cpp +++ b/util/unicode/codecs/big5/main.cpp @@ -98,23 +98,17 @@ int main(int argc, char **argv) }; QList list; - foreach(Map m, b5_to_uc_map) { + for (Map m : std::as_const(b5_to_uc_map)) { if (!uc_ok.contains(m.b5)) list += QByteArray(" { 0x" + QByteArray::number(m.b5, 16) + ", 0x" + QByteArray::number(m.uc, 16) + " }\n");; } - QByteArray ba; std::sort(list.begin(), list.end()); - foreach(QByteArray a, list) - ba += a; - qDebug() << "struct B5Map b5_to_uc_map = {\n" << ba + "\n};"; + qDebug() << "struct B5Map b5_to_uc_map = {\n" << list.join() + "\n};"; list = QList(); - foreach(Map m, uc_to_b5_map) + for (Map m : std::as_const(uc_to_b5_map)) if (!b5_ok.contains(m.uc)) list += QByteArray(" { 0x" + QByteArray::number(m.uc, 16) + ", 0x" + QByteArray::number(m.b5, 16) + " }\n");; - ba = QByteArray(); std::sort(list.begin(), list.end());; - foreach(QByteArray a, list) - ba += a; - qDebug() << "struct B5Map uc_to_b5_map = {\n" << ba + "\n};"; + qDebug() << "struct B5Map uc_to_b5_map = {\n" << list.join() + "\n};"; }