diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index c293cf11feb..9654a6712b0 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1085,16 +1085,13 @@ void qSetGlobalQHashSeed(int newSeed) */ uint qt_hash(QStringView key, uint chained) noexcept { - auto n = key.size(); - auto p = key.utf16(); - uint h = chained; - while (n--) { - h = (h << 4) + *p++; + for (auto c: key) { + h = (h << 4) + c.unicode(); h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; } + h &= 0x0fffffff; return h; }