diff options
| author | Patrick Walton <[email protected]> | 2011-04-22 19:26:00 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-22 19:26:00 -0700 |
| commit | 94e5ca4df862b1ff3e1fdc1c02828813050845d6 (patch) | |
| tree | e98ed5b57268b2fcbe2f5c7601c4092e87299f6b /src/comp | |
| parent | rustc: Thread the type store through everything that needs to access type str... (diff) | |
| download | rust-94e5ca4df862b1ff3e1fdc1c02828813050845d6.tar.xz rust-94e5ca4df862b1ff3e1fdc1c02828813050845d6.zip | |
rustc: Include the cname in the hash to increase entropy
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/ty.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 86a0db1f..36fb258d 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -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; } |