Make the selector hash depend on the types as well as the name - should reduce

hash collisions between typed and untyped versions.
main
theraven 15 years ago
parent c6556fd230
commit f5f0816777

@ -189,8 +189,24 @@ static inline uint32_t hash_selector(const void *s)
{ {
hash = hash * 33 + c; hash = hash * 33 + c;
} }
// FIXME: We might want to make the hash dependent on the types, since not #ifdef TYPE_DEPENDENT_DISPATCH
// doing so increases the number of potential hash collisions. // We can't use all of the values in the type encoding for the hash,
// because our equality test is a bit more complex than simple string
// encoding (for example, * and ^C have to be considered equivalent, since
// they are both used as encodings for C strings in different situations)
if ((str = sel_getType_np(sel)))
{
while((c = (uint32_t)*str++))
{
switch (c)
{
case '0'...'9':
case '@': case 'i': case 'I': case 'l': case 'L':
hash = hash * 33 + c;
}
}
}
#endif
return hash; return hash;
} }

Loading…
Cancel
Save