summaryrefslogtreecommitdiff
path: root/lib/distribute.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2010-08-27 14:11:14 -0700
committerPaul Jakma <paul@quagga.net>2011-03-21 13:30:54 +0000
commit6392aa83c4f895ebbd23817c68d9b0da0de2e0f8 (patch)
tree535c89a194ec7fd3b9f4a6e33ceab10579e62329 /lib/distribute.c
parent25ff1e88bb5f1b0a16a364d7206db3ebdc5ecf52 (diff)
lib: Better hashing of string values using Bernstein hash
* hash.{h,c}: (string_hash_make) Hash optimised for strings, current implementation using Bernstein hash, which offers a good compromise between distribution and performance. * distribute.c: (distribute_hash_make) use previous instead of additive string hash. * if_rmap.c: (if_rmap_hash_make) ditto
Diffstat (limited to 'lib/distribute.c')
-rw-r--r--lib/distribute.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/distribute.c b/lib/distribute.c
index 242a225c..420849da 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -114,16 +114,11 @@ distribute_get (const char *ifname)
}
static unsigned int
-distribute_hash_make (struct distribute *dist)
+distribute_hash_make (void *arg)
{
- unsigned int i, key;
+ const struct distribute *dist = arg;
- key = 0;
- if (dist->ifname)
- for (i = 0; i < strlen (dist->ifname); i++)
- key += dist->ifname[i];
-
- return key;
+ return dist->ifname ? string_hash_make (dist->ifname) : 0;
}
/* If two distribute-list have same value then return 1 else return
@@ -763,7 +758,7 @@ distribute_list_reset ()
void
distribute_list_init (int node)
{
- disthash = hash_create ((unsigned int (*) (void *)) distribute_hash_make,
+ disthash = hash_create (distribute_hash_make,
(int (*) (const void *, const void *)) distribute_cmp);
if(node==RIP_NODE) {