diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2020-05-08 23:31:48 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2020-05-11 08:45:44 +0200 |
commit | 36e5a9d025ce7132c65fae0bf6ce59e179950b88 (patch) | |
tree | 46926bed3385bb89c0e95cc25d3d8f5376d66fd2 /src | |
parent | 2c1425898d21fb050da69eb5f423e6f4ba86080a (diff) |
Port QtPrivate::findString() from ushort* to char16_t*
Lots of casts disappear...
Change-Id: I21be426c9e4629657990ed4c896e4fce537aa1f0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qstring.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 6b825212d3..aa3f49a619 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -12002,16 +12002,16 @@ qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringVi if (l > 500 && sl > 5) return qFindStringBoyerMoore(haystack0, from, needle0, cs); - auto sv = [sl](const ushort *v) { return QStringView(v, sl); }; + auto sv = [sl](const char16_t *v) { return QStringView(v, sl); }; /* We use some hashing for efficiency's sake. Instead of comparing strings, we compare the hash value of str with that of a part of this QString. Only if that matches, we call qt_string_compare(). */ - const ushort *needle = (const ushort *)needle0.data(); - const ushort *haystack = (const ushort *)(haystack0.data()) + from; - const ushort *end = (const ushort *)(haystack0.data()) + (l - sl); + const char16_t *needle = needle0.utf16(); + const char16_t *haystack = haystack0.utf16() + from; + const char16_t *end = haystack0.utf16() + (l - sl); const std::size_t sl_minus_1 = sl - 1; std::size_t hashNeedle = 0, hashHaystack = 0; qsizetype idx; @@ -12027,13 +12027,13 @@ qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringVi hashHaystack += haystack[sl_minus_1]; if (hashHaystack == hashNeedle && qt_compare_strings(needle0, sv(haystack), Qt::CaseSensitive) == 0) - return haystack - (const ushort *)haystack0.data(); + return haystack - haystack0.utf16(); REHASH(*haystack); ++haystack; } } else { - const ushort *haystack_start = (const ushort *)haystack0.data(); + const char16_t *haystack_start = haystack0.utf16(); for (idx = 0; idx < sl; ++idx) { hashNeedle = (hashNeedle<<1) + foldCase(needle + idx, needle); hashHaystack = (hashHaystack<<1) + foldCase(haystack + idx, haystack_start); @@ -12044,7 +12044,7 @@ qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringVi hashHaystack += foldCase(haystack + sl_minus_1, haystack_start); if (hashHaystack == hashNeedle && qt_compare_strings(needle0, sv(haystack), Qt::CaseInsensitive) == 0) - return haystack - (const ushort *)haystack0.data(); + return haystack - haystack0.utf16(); REHASH(foldCase(haystack, haystack_start)); ++haystack; |