Mild optimization of qt_hash

Move one AND operation out of the loop, as it is only needed in the end.

Change-Id: I48adcd18c900654830a84813f26c95eee579b49d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fc947593ef78c92b67811ac14dae200b45b480ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Allan Sandfeld Jensen 2024-11-26 12:17:21 +01:00 committed by Qt Cherry-pick Bot
parent 992f81931e
commit b325a93e34

View File

@ -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;
}