diff options
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/util/common.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index c7d94279..5243e2f7 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -50,16 +50,15 @@ fn def_eq(&ast.def_id a, &ast.def_id b) -> bool { ret a._0 == b._0 && a._1 == b._1; } -fn new_def_hash[V]() -> std.map.hashmap[ast.def_id,V] { - - fn hash(&ast.def_id d) -> uint { - let uint u = d._0 as uint; - u <<= 16u; - u |= d._1 as uint; - ret u; - } +fn hash_def(&ast.def_id d) -> uint { + auto h = 5381u; + h = ((h << 5u) + h) ^ (d._0 as uint); + h = ((h << 5u) + h) ^ (d._1 as uint); + ret h; +} - let std.map.hashfn[ast.def_id] hasher = hash; +fn new_def_hash[V]() -> std.map.hashmap[ast.def_id,V] { + let std.map.hashfn[ast.def_id] hasher = hash_def; let std.map.eqfn[ast.def_id] eqer = def_eq; ret std.map.mk_hashmap[ast.def_id,V](hasher, eqer); } |