From 6392aa83c4f895ebbd23817c68d9b0da0de2e0f8 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 27 Aug 2010 14:11:14 -0700 Subject: 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 --- lib/if_rmap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/if_rmap.c') diff --git a/lib/if_rmap.c b/lib/if_rmap.c index ddc62fd5..9774be4b 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -109,14 +109,9 @@ if_rmap_get (const char *ifname) static unsigned int if_rmap_hash_make (void *data) { - struct if_rmap *if_rmap = data; - unsigned int i, key; + const struct if_rmap *if_rmap = data; - key = 0; - for (i = 0; i < strlen (if_rmap->ifname); i++) - key += if_rmap->ifname[i]; - - return key; + return string_hash_make (if_rmap->ifname); } static int -- cgit v1.2.3