From 94e5ca4df862b1ff3e1fdc1c02828813050845d6 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Apr 2011 19:26:00 -0700 Subject: rustc: Include the cname in the hash to increase entropy --- src/comp/middle/ty.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/comp') 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; } -- cgit v1.2.3