summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qhash.cpp')
-rw-r--r--src/corelib/tools/qhash.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index ed756cbeb6..59e7a979dc 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -235,17 +235,16 @@ static void qt_initialize_qhash_seed()
\internal
Private copy of the implementation of the Qt 4 qHash algorithm for strings,
+ (that is, QChar-based arrays, so all QString-like classes),
to be used wherever the result is somehow stored or reused across multiple
Qt versions. The public qHash implementation can change at any time,
therefore one must not rely on the fact that it will always give the same
results.
- This function must *never* change its results.
+ The qt_hash functions must *never* change their results.
*/
-uint qt_hash(const QString &key) Q_DECL_NOTHROW
+static uint qt_hash(const QChar *p, int n) Q_DECL_NOTHROW
{
- const QChar *p = key.unicode();
- int n = key.size();
uint h = 0;
while (n--) {
@@ -256,6 +255,24 @@ uint qt_hash(const QString &key) Q_DECL_NOTHROW
return h;
}
+/*!
+ \internal
+ \overload
+*/
+uint qt_hash(const QString &key) Q_DECL_NOTHROW
+{
+ return qt_hash(key.unicode(), key.size());
+}
+
+/*!
+ \internal
+ \overload
+*/
+uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW
+{
+ return qt_hash(key.unicode(), key.size());
+}
+
/*
The prime_deltas array is a table of selected prime values, even
though it doesn't look like one. The primes we are using are 1,