This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A better hash for PTR_TABLE_HASH (?)
authorNicholas Clark <nick@ccl4.org>
Fri, 9 Dec 2005 23:09:42 +0000 (23:09 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 9 Dec 2005 23:09:42 +0000 (23:09 +0000)
p4raw-id: //depot/perl@26315

sv.c

diff --git a/sv.c b/sv.c
index 9ed37cb..30b499d 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -9031,11 +9031,8 @@ Perl_ptr_table_new(pTHX)
     return tbl;
 }
 
-#if (PTRSIZE == 8)
-#  define PTR_TABLE_HASH(ptr) (PTR2UV(ptr) >> 3)
-#else
-#  define PTR_TABLE_HASH(ptr) (PTR2UV(ptr) >> 2)
-#endif
+#define PTR_TABLE_HASH(ptr) \
+  ((PTR2UV(ptr) >> 3) ^ (PTR2UV(ptr) >> (3 + 7)) ^ (PTR2UV(ptr) >> (3 + 17)))
 
 /* 
    we use the PTE_SVSLOT 'reservation' made above, both here (in the