diff options
Diffstat (limited to 'tests/benchmarks/corelib/tools/qhash/outofline.cpp')
-rw-r--r-- | tests/benchmarks/corelib/tools/qhash/outofline.cpp | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/tests/benchmarks/corelib/tools/qhash/outofline.cpp b/tests/benchmarks/corelib/tools/qhash/outofline.cpp index 8adaa0a04f..75d99f96f8 100644 --- a/tests/benchmarks/corelib/tools/qhash/outofline.cpp +++ b/tests/benchmarks/corelib/tools/qhash/outofline.cpp @@ -57,50 +57,6 @@ uint qHash(const Qt4String &str) return h; } -static void doHash(const unsigned short *p, uint &h) -{ -#if 1 - // Copied from static uint hash(const QChar *p, int n). - // Possibly not the cheapest way. - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - - h = (h << 4) + (*p++); - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; -#else - // Faster, but probably less spread. - h ^= *(unsigned int *)p; -#endif -} - -uint qHash(const String &str) -{ - const unsigned short *p = (unsigned short *)str.constData(); - const int s = str.size(); - switch (s) { - case 0: return 0; - case 1: return *p; - case 2: return *(unsigned int *)p; - case 3: return (*(unsigned int *)p) ^ *(p + 2); - //case 3: return (*p << 11) + (*(p + 1) << 22) + *(p + 2); - } - uint h = 0; - doHash(p, h); - doHash(p + s / 2 - 2, h); - doHash(p + s - 4, h); - return h; -} - // The Java's hashing algorithm for strings is a variation of D. J. Bernstein // hashing algorithm appeared here http://cr.yp.to/cdb/cdb.txt // and informally known as DJB33XX - DJB's 33 Times Xor. |