@@ -42,13 +42,15 @@ impl StableHasher {
42
42
}
43
43
44
44
impl StableHasherResult for u128 {
45
+ #[ inline]
45
46
fn finish ( hasher : StableHasher ) -> Self {
46
47
let ( _0, _1) = hasher. finalize ( ) ;
47
48
u128:: from ( _0) | ( u128:: from ( _1) << 64 )
48
49
}
49
50
}
50
51
51
52
impl StableHasherResult for u64 {
53
+ #[ inline]
52
54
fn finish ( hasher : StableHasher ) -> Self {
53
55
hasher. finalize ( ) . 0
54
56
}
@@ -559,8 +561,16 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
559
561
SK : HashStable < HCX > + Ord ,
560
562
F : Fn ( & K , & HCX ) -> SK ,
561
563
{
562
- let mut entries: SmallVec < [ _ ; 3 ] > =
563
- map. iter ( ) . map ( |( k, v) | ( to_stable_hash_key ( k, hcx) , v) ) . collect ( ) ;
564
- entries. sort_unstable_by ( |& ( ref sk1, _) , & ( ref sk2, _) | sk1. cmp ( sk2) ) ;
565
- entries. hash_stable ( hcx, hasher) ;
564
+ let hash = map
565
+ . iter ( )
566
+ . map ( |( key, value) | {
567
+ let key = to_stable_hash_key ( key, hcx) ;
568
+ let mut hasher = StableHasher :: new ( ) ;
569
+ key. hash_stable ( hcx, & mut hasher) ;
570
+ value. hash_stable ( hcx, & mut hasher) ;
571
+ hasher. finish :: < u128 > ( )
572
+ } )
573
+ . reduce ( |accum, value| accum. wrapping_mul ( value) ) ;
574
+ map. len ( ) . hash_stable ( hcx, hasher) ;
575
+ hash. hash_stable ( hcx, hasher) ;
566
576
}
0 commit comments