From: Nick Mathewson Date: Sat, 10 Jan 2009 14:37:45 +0000 (+0000) Subject: Improve the hashsocket function. X-Git-Tag: release-2.0.1-alpha~186 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91e3ead85eb81c3f8aabb8a193e3cc952755d87a;p=libevent Improve the hashsocket function. svn:r989 --- diff --git a/evmap.c b/evmap.c index d74da260..65951493 100644 --- a/evmap.c +++ b/evmap.c @@ -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