[runtime] Use better hashing for refobject_hash
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 17 Feb 2017 00:25:44 +0000 (02:25 +0200)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 20 Feb 2017 12:24:25 +0000 (14:24 +0200)
mono/metadata/reflection.c

index 1ddb08757a35cf6ad594485318d1edbe172b5bb9..bf97132d85e790303aeae59ca66df1ab97c34138 100644 (file)
@@ -165,7 +165,10 @@ reflected_equal (gconstpointer a, gconstpointer b)
 guint
 reflected_hash (gconstpointer a) {
        const ReflectedEntry *ea = (const ReflectedEntry *)a;
-       return mono_aligned_addr_hash (ea->item);
+       /* Combine hashes for item and refclass. Identical to boost's hash_combine */
+       guint seed = mono_aligned_addr_hash (ea->item) + 0x9e3779b9;
+       seed ^= mono_aligned_addr_hash (ea->refclass) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
+       return seed;
 }