[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Avoid floating point in hash table implementation.
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 56ee79e28f1dfdd0da9711bd866d4d4765e93a3e # Parent 578a7cd07970be6836fcc8d58b503469e5abf0de Avoid floating point in hash table implementation. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> diff -r 578a7cd07970 -r 56ee79e28f1d tools/xenstore/hashtable.c --- a/tools/xenstore/hashtable.c Wed Mar 8 22:57:59 2006 +++ b/tools/xenstore/hashtable.c Wed Mar 8 22:58:05 2006 @@ -6,6 +6,7 @@ #include <stdio.h> #include <string.h> #include <math.h> +#include <stdint.h> /* Credit for primes table: Aaron Krowne @@ -22,7 +23,7 @@ 805306457, 1610612741 }; const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]); -const float max_load_factor = 0.65; +const unsigned int max_load_factor = 65; /* percentage */ /*****************************************************************************/ struct hashtable * @@ -48,7 +49,7 @@ h->entrycount = 0; h->hashfn = hashf; h->eqfn = eqf; - h->loadlimit = (unsigned int) ceil(size * max_load_factor); + h->loadlimit = (unsigned int)(((uint64_t)size * max_load_factor) / 100); return h; } @@ -121,7 +122,8 @@ } } h->tablelength = newsize; - h->loadlimit = (unsigned int) ceil(newsize * max_load_factor); + h->loadlimit = (unsigned int) + (((uint64_t)newsize * max_load_factor) / 100); return -1; } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |