@@ -13,24 +13,13 @@ use std::marker::PhantomData;
13
13
use std:: mem;
14
14
use sip128:: SipHasher128 ;
15
15
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*.
19
19
///
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.
34
23
pub struct StableHasher < W > {
35
24
state : SipHasher128 ,
36
25
bytes_hashed : u64 ,
@@ -86,9 +75,6 @@ impl<W> StableHasher<W> {
86
75
}
87
76
}
88
77
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.
92
78
impl < W > Hasher for StableHasher < W > {
93
79
fn finish ( & self ) -> u64 {
94
80
panic ! ( "use StableHasher::finalize instead" ) ;
0 commit comments