QHash: fix iteration of x86 AES hash code for len >= 32

[ChangeLog][QtCore][QHash] Fixed a bug in the qHashBits() function,
which affected the hashing of QByteArray, QString (and their View
classes), QLatin1String and QBitArray, which caused the hash to not
include the final 32 bytes of the data source. As a result, QHash
containers where the initial string was the same had a serious
performance degradation on x86 CPUs with AES support.

Fixes: QTBUG-91739
Pick-to: 6.2.3 6.2 6.3
Change-Id: Icad7c1bad46a449c8e8afffd16cb74dd43440f6c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Thiago Macieira 2022-01-18 11:43:02 -08:00
parent 517821b173
commit b5d480d01d
1 changed files with 2 additions and 2 deletions

View File

@ -564,8 +564,8 @@ static size_t aeshash(const uchar *p, size_t len, size_t seed, size_t seed2) noe
// do simplified rounds of 32 bytes: unlike the Go code, we only
// scramble twice and we keep 256 bits of state
const auto srcend = src + (len / 32);
while (src < srcend) {
const auto srcend = reinterpret_cast<const __m128i *>(p + len);
while (src + 2 <= srcend) {
__m128i data0 = _mm_loadu_si128(src);
__m128i data1 = _mm_loadu_si128(src + 1);
state0 = _mm_xor_si128(data0, state0);