Use the same hash for 8 bit strings as in QByteArray
authorLars Knoll <lars.knoll@nokia.com>
Fri, 7 Sep 2012 13:11:36 +0000 (15:11 +0200)
committerQt by Nokia <qt-info@nokia.com>
Sun, 9 Sep 2012 19:05:55 +0000 (21:05 +0200)
Moc still used a different and quite a bit more complicated
algorithm to hash 8bit strings then QByteArray.

Change-Id: I86efb08d5ab7de1863fc168dcfc73399e72e1331
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/tools/moc/symbols.h

index eadb2db..a53cc18 100644 (file)
@@ -72,18 +72,7 @@ struct SubArray
 
 inline uint qHash(const SubArray &key)
 {
-    const uchar *p = reinterpret_cast<const uchar *>(key.array.data() + key.from);
-    int n = key.len;
-    uint h = 0;
-    uint g;
-
-    while (n--) {
-        h = (h << 4) + *p++;
-        if ((g = (h & 0xf0000000)) != 0)
-            h ^= g >> 23;
-        h &= ~g;
-    }
-    return h;
+    return qHash(QLatin1String(key.array.constData() + key.from, key.len));
 }