summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <dangelog@gmail.com>2012-03-22 09:32:03 +0000
committerQt by Nokia <qt-info@nokia.com>2012-04-08 21:44:26 +0200
commitddb70bee2fd323ddc4273aec5d40d975f50d2904 (patch)
tree660da583fa2dfc58436fb77c719ace9708da33f9 /util
parentea17c21fd8b93a94027fad7d3827904ae96e2a3b (diff)
Stop relying on qHash always giving the same results
The implementation of the various qHash overloads offered by Qt can change at any time for any reason (speed, quality, security, ...). Therefore, relying on the fact that qHash will always give an identical result across Qt versions (... across different processes, etc.), given identical input, is wrong. Note that this also implies that one cannot rely on QHash having a stable ordering (even without the random qHash seed). For such use cases, one must use f.i. a private hash function that will never change outside his own control. This patch adds a private hash function for QStrings, which is identical to the Qt(4) qHash(QString) implementation. A couple of spots in Qt where the results of a qHash call were actually saved on disk are ported to use the new function, and a bit of documentation is added to QHash docs. Change-Id: Ia3731ea26ac68649b535b95e9f36fbec3df693c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'util')
-rw-r--r--util/corelib/qurl-generateTLDs/main.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/corelib/qurl-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp
index b003ff0428..3d46bd9401 100644
--- a/util/corelib/qurl-generateTLDs/main.cpp
+++ b/util/corelib/qurl-generateTLDs/main.cpp
@@ -103,7 +103,7 @@ int main(int argc, char **argv) {
while (!file.atEnd()) {
QString s = QString::fromUtf8(file.readLine());
QString st = s.trimmed();
- int num = qHash(st) % lineCount;
+ int num = qt_hash(st) % lineCount;
QString utf8String = utf8encode(st.toUtf8());