From 90645f5598ca8b25cd2692f2ac0d2778a3fd2755 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 4 Jan 2013 22:29:21 +0000 Subject: hash: force size to be a power of 2 By forcing the hash table size to be a power of 2, a potentially expensive divide can be replaced by a mask operation. Almost all usage of the hash table was using default size of 1024. Only places with different size was thread library (1011) and bgp aspath. Signed-off-by: David Lamparter --- lib/thread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/thread.c') diff --git a/lib/thread.c b/lib/thread.c index 16c92c24..27c29d6c 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -531,8 +531,8 @@ thread_master_create () { if (cpu_record == NULL) cpu_record - = hash_create_size (1011, (unsigned int (*) (void *))cpu_record_hash_key, - (int (*) (const void *, const void *))cpu_record_hash_cmp); + = hash_create ((unsigned int (*) (void *))cpu_record_hash_key, + (int (*) (const void *, const void *))cpu_record_hash_cmp); return (struct thread_master *) XCALLOC (MTYPE_THREAD_MASTER, sizeof (struct thread_master)); -- cgit v1.2.1