File tree 1 file changed +17
-9
lines changed
compiler/rustc_data_structures/src
1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -559,20 +559,28 @@ where
559
559
fn stable_hash_reduce < HCX , I , C , F > (
560
560
hcx : & mut HCX ,
561
561
hasher : & mut StableHasher ,
562
- collection : C ,
562
+ mut collection : C ,
563
563
length : usize ,
564
564
hash_function : F ,
565
565
) where
566
566
C : Iterator < Item = I > ,
567
567
F : Fn ( & mut StableHasher , & mut HCX , I ) ,
568
568
{
569
- let hash = collection
570
- . map ( |value| {
571
- let mut hasher = StableHasher :: new ( ) ;
572
- hash_function ( & mut hasher, hcx, value) ;
573
- hasher. finish :: < u128 > ( )
574
- } )
575
- . reduce ( |accum, value| accum. wrapping_add ( value) ) ;
576
569
length. hash_stable ( hcx, hasher) ;
577
- hash. hash_stable ( hcx, hasher) ;
570
+
571
+ match length {
572
+ 1 => {
573
+ hash_function ( hasher, hcx, collection. next ( ) . unwrap ( ) ) ;
574
+ }
575
+ _ => {
576
+ let hash = collection
577
+ . map ( |value| {
578
+ let mut hasher = StableHasher :: new ( ) ;
579
+ hash_function ( & mut hasher, hcx, value) ;
580
+ hasher. finish :: < u128 > ( )
581
+ } )
582
+ . reduce ( |accum, value| accum. wrapping_add ( value) ) ;
583
+ hash. hash_stable ( hcx, hasher) ;
584
+ }
585
+ }
578
586
}
You can’t perform that action at this time.
0 commit comments