@@ -48,21 +48,16 @@ rust_crate_cache::get_type_desc(size_t size,
48
48
void **
49
49
rust_crate_cache::get_dict (size_t n_fields, void ** dict) {
50
50
rust_hashable_dict *found = NULL ;
51
- uintptr_t key = 0 ;
52
- for (size_t i = 0 ; i < n_fields; ++i) key ^= (uintptr_t )dict[i];
53
- size_t keysz = sizeof (uintptr_t );
54
- HASH_FIND (hh, this ->dicts , &key, keysz, found);
55
- if (found) { printf (" found!\n " ); return &(found->fields [0 ]); }
56
- printf (" not found\n " );
57
- size_t dictsz = n_fields * sizeof (void *);
51
+ size_t dictsz = sizeof (void *) * n_fields;
52
+ HASH_FIND (hh, this ->dicts , dict, dictsz, found);
53
+ if (found) return &(found->fields [0 ]);
58
54
found = (rust_hashable_dict*)
59
- sched->kernel ->malloc (keysz + sizeof (UT_hash_handle) + dictsz,
55
+ sched->kernel ->malloc (sizeof (UT_hash_handle) + dictsz,
60
56
" crate cache dict" );
61
57
if (!found) return NULL ;
62
- found->key = key;
63
58
void ** retptr = &(found->fields [0 ]);
64
59
memcpy (retptr, dict, dictsz);
65
- HASH_ADD (hh, this ->dicts , key, keysz , found);
60
+ HASH_ADD_KEYPTR (hh, this ->dicts , retptr, dictsz , found);
66
61
return retptr;
67
62
}
68
63
0 commit comments