rustc: Include the cname in the hash to increase entropy

This commit is contained in:
Patrick Walton 2011-04-22 19:26:00 -07:00
parent e0eccaddb2
commit 94e5ca4df8

View file

@ -120,7 +120,7 @@ fn gen_ty(@type_store tystore, &sty st) -> t {
}
fn gen_ty_full(@type_store tystore, &sty st, option.t[str] cname) -> t {
auto h = hash_type_structure(st);
auto h = hash_type_info(st, cname);
auto new_type = @rec(struct=st, cname=cname, hash=h);
// Is it interned?
@ -888,6 +888,15 @@ fn hash_type_structure(&sty st) -> uint {
}
}
fn hash_type_info(&sty st, option.t[str] cname_opt) -> uint {
auto h = hash_type_structure(st);
alt (cname_opt) {
case (none[str]) { /* no-op */ }
case (some[str](?s)) { h += h << 5u + _str.hash(s); }
}
ret h;
}
fn hash_ty(&t typ) -> uint { ret typ.hash; }