diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2024-02-05 15:53:39 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-03-12 17:23:11 -0800 |
commit | 45fd36f1480a6229879a4e59236ffa1d1d22dfbf (patch) | |
tree | e62c063267fe8237b37337e9c9fe435c44568c52 /src/corelib/tools | |
parent | fff9f5047af79e7a8bd7345d9f22126d626e35a7 (diff) |
qHash: make hashing of QLatin1StringView be the same as QString
Everywhere, except for ARM.
Change-Id: I50e2158aeade4256ad1dfffd17b11ca2d57ad1fb
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 11 | ||||
-rw-r--r-- | src/corelib/tools/qhashfunctions.h | 6 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 87ccc46d71..af393b9235 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1140,21 +1140,12 @@ size_t qHash(QLatin1StringView key, size_t seed) noexcept // the seed is always 0 in bootstrapped mode (no seed generation code), // so help the compiler do dead code elimination seed = 0; - constexpr bool Qt6DeterministicHash = true; -#else - constexpr bool Qt6DeterministicHash = QT_VERSION_MAJOR == 6; #endif auto data = reinterpret_cast<const uchar *>(key.data()); size_t size = key.size(); - if (seed == 0 && Qt6DeterministicHash) { - // fall back to what we used to use prior to Qt 6.8 - return qHashBits(data, size, seed); - } - - // mix in the length as a secondary seed. For seed == 0, seed2 must be - // size, to match what we used to do prior to Qt 6.2. + // Mix in the length as a secondary seed. // Multiplied by 2 to match the byte size of the equiavlent UTF-16 string. size_t seed2 = size * 2; if (seed) diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index 9056d24102..90a269deaa 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -58,6 +58,12 @@ template <> struct QHashHeterogeneousSearch<QString, QStringView> : std::true_ty template <> struct QHashHeterogeneousSearch<QStringView, QString> : std::true_type {}; template <> struct QHashHeterogeneousSearch<QByteArray, QByteArrayView> : std::true_type {}; template <> struct QHashHeterogeneousSearch<QByteArrayView, QByteArray> : std::true_type {}; +#ifndef Q_PROCESSOR_ARM +template <> struct QHashHeterogeneousSearch<QString, QLatin1StringView> : std::true_type {}; +template <> struct QHashHeterogeneousSearch<QStringView, QLatin1StringView> : std::true_type {}; +template <> struct QHashHeterogeneousSearch<QLatin1StringView, QString> : std::true_type {}; +template <> struct QHashHeterogeneousSearch<QLatin1StringView, QStringView> : std::true_type {}; +#endif namespace QHashPrivate { |