Simplify THREAD_TABLE_INDEX expression for Win32/64
authorIvan Maidanski <ivmai@mail.ru>
Fri, 25 Aug 2017 06:53:07 +0000 (09:53 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 25 Aug 2017 06:53:07 +0000 (09:53 +0300)
(fix commit 85fce54)

Windows thread Id rarely has non-zero highest half of DWORD, so
it is OK to use only the lowest one for hash value computation.

* win32_threads.c (THREAD_TABLE_INDEX): Remove (id>>16) from the
expression.

win32_threads.c

index 7befb9b..3cbdc22 100644 (file)
@@ -321,7 +321,7 @@ STATIC volatile LONG GC_max_thread_index = 0;
 # define THREAD_TABLE_SZ 256    /* Power of 2 (for speed). */
 #endif
 #define THREAD_TABLE_INDEX(id) /* id is of DWORD type */ \
-                (int)((((id) >> 16) ^ ((id) >> 8) ^ (id)) % THREAD_TABLE_SZ)
+                (int)((((id) >> 8) ^ (id)) % THREAD_TABLE_SZ)
 STATIC GC_thread GC_threads[THREAD_TABLE_SZ];
 
 /* It may not be safe to allocate when we register the first thread.    */