diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-18 11:43:02 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-21 14:08:01 -0800 |
commit | b5d480d01d9f8a3cd97c614f579008ac137c9174 (patch) | |
tree | 133c74f7852c937b06e6d1b62a67c42d4c253aa5 /src/corelib | |
parent | 517821b1730695dc41403668854871c746face26 (diff) |
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>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 0de69ad20a..c6373ee11d 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -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); |