From 970aad541811d002e5004bd3826929247492ba09 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Feb 2024 20:00:33 -0800 Subject: qHash: implement chunked hashing of QLatin1StringView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that it hashes to the same value as QString{,View}. In order to test this, you must either run on a CPU other than ARM and x86, or disable the AES hasher. I did that and can confirm siphash and murmurhash do work with on-the-fly conversion from Latin-1. Change-Id: I664b9f014ffc48cbb49bfffd17b03e5e62ec4e89 Reviewed-by: MÃ¥rten Nordheim --- .../corelib/tools/qhashfunctions/tst_qhashfunctions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp') diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index b9a7d88056..fdb2b37346 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -321,6 +321,19 @@ void tst_QHashFunctions::stringConsistency() QCOMPARE(qHash(sv, seed), qHash(value, seed)); QCOMPARE(qHash(u8bav, seed), qHash(u8ba, seed)); + + if (seed || QT_VERSION_MAJOR > 6) { + QByteArray l1ba = value.toLatin1(); + QLatin1StringView l1sv(l1ba.data(), l1ba.size()); +#ifdef Q_PROCESSOR_ARM + // zero-extending aeshash not implemented on ARM +#elif defined(Q_PROCESSOR_X86) + // zero-extending aeshash not implemented on x86 +#else + if (value == l1sv) + QCOMPARE(qHash(l1sv, seed), qHash(value, seed)); +#endif + } } void tst_QHashFunctions::qhash() -- cgit v1.2.3