@@ -13,24 +13,13 @@ use std::marker::PhantomData;
1313use std:: mem;
1414use sip128:: SipHasher128 ;
1515
16- /// When hashing something that ends up affecting properties like symbol names. We
17- /// want these symbol names to be calculated independent of other factors like
18- /// what architecture you're compiling *from*.
16+ /// When hashing something that ends up affecting properties like symbol names,
17+ /// we want these symbol names to be calculated independently of other factors
18+ /// like what architecture you're compiling *from*.
1919///
20- /// The hashing just uses the standard `Hash` trait, but the implementations of
21- /// `Hash` for the `usize` and `isize` types are *not* architecture independent
22- /// (e.g. they has 4 or 8 bytes). As a result we want to avoid `usize` and
23- /// `isize` completely when hashing.
24- ///
25- /// To do that, we encode all integers to be hashed with some
26- /// arch-independent encoding.
27- ///
28- /// At the moment, we pass i8/u8 straight through and encode
29- /// all other integers using leb128.
30- ///
31- /// This hasher currently always uses the stable Blake2b algorithm
32- /// and allows for variable output lengths through its type
33- /// parameter.
20+ /// To that end we always convert integers to little-endian format before
21+ /// hashing and the architecture dependent `isize` and `usize` types are
22+ /// extended to 64 bits if needed.
3423pub struct StableHasher < W > {
3524 state : SipHasher128 ,
3625 bytes_hashed : u64 ,
@@ -86,9 +75,6 @@ impl<W> StableHasher<W> {
8675 }
8776}
8877
89- // For the non-u8 integer cases we leb128 encode them first. Because small
90- // integers dominate, this significantly and cheaply reduces the number of
91- // bytes hashed, which is good because blake2b is expensive.
9278impl < W > Hasher for StableHasher < W > {
9379 fn finish ( & self ) -> u64 {
9480 panic ! ( "use StableHasher::finalize instead" ) ;
0 commit comments