Skip to content

Commit

Permalink
Typed hash shift. Fixes dimforge#117
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrikNoren committed Jan 9, 2016
1 parent 01481a5 commit 329cbb6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ncollide_utils/data/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ pub fn key_from_pair(a: usize, b: usize) -> usize {
pub fn tomas_wang_hash(k: usize) -> usize {
let mut res = Wrapping(k);

res = res + !(res << 32);
let x: Wrapping<usize> = res << 32;
res = res + !(x);
res = res ^ (res >> 22);
res = res + !(res << 13);
let x: Wrapping<usize> = res << 13;
res = res + !(x);
res = res ^ (res >> 8);
res = res + (res << 3);
res = res ^ (res >> 15);
res = res + !(res << 27);
let x: Wrapping<usize> = res << 27;
res = res + !(x);
res = res ^ (res >> 31);

let Wrapping(res_val) = res;
Expand Down

0 comments on commit 329cbb6

Please sign in to comment.