Improve the hashsocket function.

svn:r989
This commit is contained in:
Nick Mathewson 2009-01-10 14:37:45 +00:00
parent 55bcd7d2f0
commit 91e3ead85e

View File

@ -91,7 +91,12 @@ struct event_map_entry {
static inline unsigned
hashsocket(struct event_map_entry *e)
{
return (unsigned) e->fd;
/* On win32, in practice, the low 2-3 bits of a SOCKET seem not to
* matter. Our hashtable implementation really likes low-order bits,
* though, so let's do the rotate-and-add trick. */
unsigned h = (unsigned) e->fd;
h += (h >> 2) | (h << 30);
return h;
}
static inline int