diff options
author | Robin Burchell <robin+qt@viroteck.net> | 2012-02-28 21:04:53 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-29 22:39:00 +0100 |
commit | b147da00c5fec9d89a2b60d10e82ac28766e2a5b (patch) | |
tree | af4de605a25c559e9268de5654e0e4ddd7a668ea /tests/benchmarks/corelib/tools/qhash/outofline.cpp | |
parent | 1f4804452c05c57308979bf090305c7c882f92c9 (diff) |
Remove qhash_faster.
It's not faster under _any_ metric than the new algorithm, and it loses a lot of
spread which is a bad thing.
Change-Id: Ic87258f1c887822ffea1cb1517355564fabc3c26
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
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. |