Skip to content

Commit

Permalink
incr.comp.: Use 128-bit Metrohash instead of BLAKE2 for computing ICHs.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Oct 4, 2017
1 parent c597d45 commit ea204a4
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 64 deletions.
15 changes: 4 additions & 11 deletions src/librustc/ich/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

use rustc_data_structures::stable_hasher;
use std::mem;
use std::slice;
// use std::mem;
// use std::slice;

#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
pub struct Fingerprint(u64, u64);
Expand Down Expand Up @@ -55,15 +55,8 @@ impl ::std::fmt::Display for Fingerprint {

impl stable_hasher::StableHasherResult for Fingerprint {
fn finish(mut hasher: stable_hasher::StableHasher<Self>) -> Self {
let hash_bytes: &[u8] = hasher.finalize();

assert!(hash_bytes.len() >= mem::size_of::<u64>() * 2);
let hash_bytes: &[u64] = unsafe {
slice::from_raw_parts(hash_bytes.as_ptr() as *const u64, 2)
};

// The bytes returned bytes the Blake2B hasher are always little-endian.
Fingerprint(u64::from_le(hash_bytes[0]), u64::from_le(hash_bytes[1]))
let (_0, _1) = hasher.finalize();
Fingerprint(_0, _1)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![feature(fn_traits)]
#![feature(unsize)]
#![feature(i128_type)]
#![feature(i128)]
#![feature(conservative_impl_trait)]
#![feature(specialization)]

Expand Down
Loading

0 comments on commit ea204a4

Please sign in to comment.