[core] splaytree: use all 32-bits of hash value
This commit is contained in:
parent
acff6cd34b
commit
b7eeb1d992
|
@ -52,9 +52,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define compare(i,j) ((i)-(j))
|
||||
#define compare(i,j) ((int)(((unsigned int)i)-((unsigned int)j)))
|
||||
/* This is the comparison. */
|
||||
/* Returns <0 if i<j, =0 if i=j, and >0 if i>j */
|
||||
/* (cast to unsigned int for underflow/overflow defined behavior)*/
|
||||
|
||||
/* Splay using the key i (which may or may not be in the tree.)
|
||||
* The starting root is t, and the tree used is defined by rat
|
||||
|
|
|
@ -20,8 +20,7 @@ __attribute_pure__
|
|||
static inline int32_t splaytree_djbhash(const char *str, const uint32_t len);
|
||||
static inline int32_t splaytree_djbhash(const char *str, const uint32_t len)
|
||||
{
|
||||
/* strip highest bit of hash value for splaytree */
|
||||
return (int32_t)(djbhash(str,len,DJBHASH_INIT) & ~(((uint32_t)1) << 31));
|
||||
return (int32_t)djbhash(str, len, DJBHASH_INIT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -117,14 +117,15 @@ http_auth_cache_init (const array *opts)
|
|||
return ac;
|
||||
}
|
||||
|
||||
__attribute_pure__
|
||||
static int
|
||||
http_auth_cache_hash (const struct http_auth_require_t * const require, const char *username, const uint32_t ulen)
|
||||
{
|
||||
/* (similar to splaytree_djbhash(), but with two strings hashed) */
|
||||
uint32_t h = /*(hash pointer value, which includes realm and permissions)*/
|
||||
djbhash((char *)(intptr_t)require, sizeof(intptr_t), DJBHASH_INIT);
|
||||
h = djbhash(username, ulen, h);
|
||||
/* strip highest bit of hash value for splaytree (see splaytree_djbhash())*/
|
||||
return (int32_t)(h & ~(((uint32_t)1) << 31));
|
||||
return (int32_t)h;
|
||||
}
|
||||
|
||||
static http_auth_cache_entry *
|
||||
|
|
Loading…
Reference in New Issue