about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-10-26 11:10:07 +0200
committerMichael Woerister <michaelwoerister@posteo>2017-10-26 11:10:07 +0200
commit54818b3e99b57f69785c29ddfa8b74d8a611258d (patch)
tree8ff16b4b207e43e032d51008a0eccdb8f4b4a7c9 /src/librustc_data_structures
parent89909c76a37d38aab57462ffdae5bed7172b02e3 (diff)
downloadrust-54818b3e99b57f69785c29ddfa8b74d8a611258d.tar.gz
rust-54818b3e99b57f69785c29ddfa8b74d8a611258d.zip
Update some comments about StableHasher.
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/stable_hasher.rs26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs
index 4849210aed3..d82b712b5b1 100644
--- a/src/librustc_data_structures/stable_hasher.rs
+++ b/src/librustc_data_structures/stable_hasher.rs
@@ -13,24 +13,13 @@ use std::marker::PhantomData;
 use std::mem;
 use sip128::SipHasher128;
 
-/// When hashing something that ends up affecting properties like symbol names. We
-/// want these symbol names to be calculated independent of other factors like
-/// what architecture you're compiling *from*.
+/// When hashing something that ends up affecting properties like symbol names,
+/// we want these symbol names to be calculated independently of other factors
+/// like what architecture you're compiling *from*.
 ///
-/// The hashing just uses the standard `Hash` trait, but the implementations of
-/// `Hash` for the `usize` and `isize` types are *not* architecture independent
-/// (e.g. they has 4 or 8 bytes). As a result we want to avoid `usize` and
-/// `isize` completely when hashing.
-///
-/// To do that, we encode all integers to be hashed with some
-/// arch-independent encoding.
-///
-/// At the moment, we pass i8/u8 straight through and encode
-/// all other integers using leb128.
-///
-/// This hasher currently always uses the stable Blake2b algorithm
-/// and allows for variable output lengths through its type
-/// parameter.
+/// To that end we always convert integers to little-endian format before
+/// hashing and the architecture dependent `isize` and `usize` types are
+/// extended to 64 bits if needed.
 pub struct StableHasher<W> {
     state: SipHasher128,
     bytes_hashed: u64,
@@ -86,9 +75,6 @@ impl<W> StableHasher<W> {
     }
 }
 
-// For the non-u8 integer cases we leb128 encode them first. Because small
-// integers dominate, this significantly and cheaply reduces the number of
-// bytes hashed, which is good because blake2b is expensive.
 impl<W> Hasher for StableHasher<W> {
     fn finish(&self) -> u64 {
         panic!("use StableHasher::finalize instead");