1
Fork 0

Add core::hash containing SipHash-2-4 implementation. Re: #1616 and #859.

This commit is contained in:
Graydon Hoare 2012-07-24 14:32:06 -07:00
parent 0737f1b53d
commit fada46c421
4 changed files with 171 additions and 13 deletions

View file

@ -660,11 +660,10 @@ pure fn le(&&a: ~str, &&b: ~str) -> bool { a <= b }
/// String hash function
pure fn hash(&&s: ~str) -> uint {
// djb hash.
// FIXME: replace with murmur. (see #859 and #1616)
let mut u: uint = 5381u;
for each(s) |c| { u *= 33u; u += c as uint; }
ret u;
let x = do as_bytes(s) |bytes| {
hash::hash_bytes(bytes)
};
ret x as uint;
}
/*