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:
parent
992f81931e
commit
b325a93e34
@ -1085,16 +1085,13 @@ void qSetGlobalQHashSeed(int newSeed)
|
|||||||
*/
|
*/
|
||||||
uint qt_hash(QStringView key, uint chained) noexcept
|
uint qt_hash(QStringView key, uint chained) noexcept
|
||||||
{
|
{
|
||||||
auto n = key.size();
|
|
||||||
auto p = key.utf16();
|
|
||||||
|
|
||||||
uint h = chained;
|
uint h = chained;
|
||||||
|
|
||||||
while (n--) {
|
for (auto c: key) {
|
||||||
h = (h << 4) + *p++;
|
h = (h << 4) + c.unicode();
|
||||||
h ^= (h & 0xf0000000) >> 23;
|
h ^= (h & 0xf0000000) >> 23;
|
||||||
h &= 0x0fffffff;
|
|
||||||
}
|
}
|
||||||
|
h &= 0x0fffffff;
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user