summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qunicodetools.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-10-23 07:44:31 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-10-28 17:08:27 +0200
commit4b4d44c56a2d821f1e25d4f20314b0d16b8c4e6f (patch)
treee75b371958647eca50886f53eebedbb1c2e9bad8 /src/corelib/text/qunicodetools.cpp
parent8fc7655e5d91cbe6b8bc9910558f92ddccb7c9a9 (diff)
QUnicodeTools: port initScripts() to QStringIterator
After fixing the roundabout way of updating 'eor' in a previous commit, this is now trivial (no nested loop). Amends c20422af13fb30751eaa58e8755c7a9a7fd20a50. Pick-to: 6.10 6.8 6.5 Change-Id: Idbbfc503f4bf3878d1fc57729224c99973bddc32 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/text/qunicodetools.cpp')
-rw-r--r--src/corelib/text/qunicodetools.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/corelib/text/qunicodetools.cpp b/src/corelib/text/qunicodetools.cpp
index d8f4d374322..b0c2036a5a1 100644
--- a/src/corelib/text/qunicodetools.cpp
+++ b/src/corelib/text/qunicodetools.cpp
@@ -2814,16 +2814,10 @@ Q_CORE_EXPORT void initScripts(QStringView string, ScriptItemArray *scripts)
qsizetype sor = 0;
QChar::Script script = QChar::Script_Common;
- for (qsizetype i = 0; i < string.size(); ++i) {
- const auto eor = i;
- char32_t ucs4 = string[i].unicode();
- if (QChar::isHighSurrogate(ucs4) && i + 1 < string.size()) {
- ushort low = string[i + 1].unicode();
- if (QChar::isLowSurrogate(low)) {
- ucs4 = QChar::surrogateToUcs4(ucs4, low);
- ++i;
- }
- }
+ QStringIterator it(string);
+ while (it.hasNext()) {
+ const auto eor = it.index();
+ const char32_t ucs4 = it.nextOrRawCodeUnit();
const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);