Tweak initial capacity calculations to always be a Mersenne number

darcs-hash:20061018230246-ac50b-3da6ada42423f5bba3f8c3fdb366ce1f352cffde.gz
This commit is contained in:
axel 2006-10-19 09:02:46 +10:00
parent c7bc31fe50
commit 8b3bcd2c4c

14
util.c
View File

@ -168,8 +168,16 @@ void hash_init2( hash_table_t *h,
size_t capacity)
{
int i;
size_t sz = capacity*4/3+1;
size_t sz = 32;
while( sz < (capacity*4/3) )
sz*=2;
/*
Make sure the size is a Mersenne number. Should hopfully be a
reasonably good size with regard to avoiding patterns of collisions.
*/
sz--;
h->arr = malloc( sizeof(hash_struct_t)*sz );
h->size = sz;
for( i=0; i< sz; i++ )
@ -489,6 +497,10 @@ static unsigned int rotl30( unsigned int in )
return (in<<30|in>>2);
}
/**
The number of words of input used in each lap by the sha-like
string hashing algorithm.
*/
#define WORD_COUNT 16
int hash_wcs_func( void *data )