[Development] What's our policy on changing the result of qHash(T, 0) between major releases?
Thiago Macieira
thiago.macieira at intel.com
Sat Feb 3 22:08:32 CET 2024
Requirement: the qHash function in question is and has always been out-of-
line. We obviously can't change the hashing function of inline code, because
it may have been inlined.
When the seed is non-zero, we make no guarantees on what the result will be.
The result is allowed to change between Qt versions and between machines, even
for the same seed. Strictly speaking, you're not supposed to pass replay a
seed, because some hash functions have a hidden seed you can't get or set.
But what about a zero seed? It's what we call a "deterministic hashing". We
have changed the algorithms on .0 releases (in both 5.0 and 6.0 for QString).
The reason I'm asking is that right now
qHash(QLatin1StringView(str)) == qHash(QByteArrayView(str))
but it would be far more useful to have
qHash(QLatin1StringView(str)) == qHash(QString(str))
I've made the change for the non-zero seeds, but one couldn't rely on the
above unless it applied for every seed.f
--
Thiago Macieira - thiago.macieira (AT) intel.com
Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5163 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240203/9de3c89c/attachment.bin>
More information about the Development
mailing list