Hi, I've always understood it such that we as Qt must preserve the property that the hash for equal elements is equal within _one_ run of _one_ process. This means you can use the hash in I/O in any way. That's why we have qt_hash, which you _can_ (and do) use in I/O (but is private API, AFAIK). I never thought that a hash seed of zero would change that, but of course users may have come to depend on this (Hyrum's Law), so a [ChangeLog] would be in order.
From that follows that you can change the hash algorithm, provided the hash function is out-of-line exported, but you can't if it's inline (or, theoretically, non-exported, because some user may have copied the implementation into his application or wrote a conflicting one; which is why I'd suggest to =delete non-Qt-provided qHash functions: to prevent users from writing their own). HTH, Marc On 03.02.24 22:08, Thiago Macieira wrote: > 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 > > -- Marc Mutz <marc.m...@qt.io> Principal Software Engineer The Qt Company Erich-Thilo-Str. 10 12489 Berlin, Germany www.qt.io Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development