diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2010-01-28 20:32:20 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2010-02-01 12:57:47 (GMT) |
commit | c830656616977d417972e2497ff3135bc562a660 (patch) | |
tree | 4906f9c0fe81b90fb22bbdda5f1a5d8932a234c7 /src | |
parent | a788f7e3a04ec741d59ef458a40e39d918dc1df0 (diff) | |
download | Qt-c830656616977d417972e2497ff3135bc562a660.zip Qt-c830656616977d417972e2497ff3135bc562a660.tar.gz Qt-c830656616977d417972e2497ff3135bc562a660.tar.bz2 |
optimize qhash()
on any modern architecture, an 1 out of 16 times needlessly executed
shift (even if a long one) and xor are less expensive than a pretty much
randomly 1 out of 16 times differently taken conditional jump. so simply
remove the conditional. ~15% faster on Core2.
Reviewed-by: joao
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index d758325..6231471 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -68,8 +68,8 @@ static uint hash(const uchar *p, int n) while (n--) { h = (h << 4) + *p++; - if ((g = (h & 0xf0000000)) != 0) - h ^= g >> 23; + g = h & 0xf0000000; + h ^= g >> 23; h &= ~g; } return h; @@ -82,8 +82,8 @@ static uint hash(const QChar *p, int n) while (n--) { h = (h << 4) + (*p++).unicode(); - if ((g = (h & 0xf0000000)) != 0) - h ^= g >> 23; + g = h & 0xf0000000; + h ^= g >> 23; h &= ~g; } return h; |