From 53180bef2d4c203027c354af573c86f658b2879c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 31 Mar 2008 18:50:24 +0000 Subject: [PATCH] Tweak hash algorithm for htable using Martin Simmons idea for doing a circular shift. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6709 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/lib/htable.c | 3 ++- bacula/technotes-2.3 | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bacula/src/lib/htable.c b/bacula/src/lib/htable.c index 280939dcf3..25cafb9f54 100644 --- a/bacula/src/lib/htable.c +++ b/bacula/src/lib/htable.c @@ -127,7 +127,8 @@ void htable::hash_index(char *key) { hash = 0; for (char *p=key; *p; p++) { - hash += (hash << 3) + (uint32_t)*p; +// hash += (hash << 3) + (uint32_t)*p; + hash += ((hash << 5) | (hash >> (sizeof(hash)*8-5))) + (uint32_t)*p; } /* Multiply by large prime number, take top bits, mask for remainder */ index = ((hash * 1103515249) >> rshift) & mask; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 9a5fd46f5b..b7dd8ccac3 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -25,6 +25,8 @@ Add long term statistics job table General: 31Mar08 +kes Tweak hash algorithm for htable using Martin Simmons idea + for doing a circular shift. kes Remember what volume is in VTLs (previously turned off for testing). kes Analysis of JobMedia records by Tom Ivar Helbekkmo -- 2.39.5