This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
compiler/rustc_data_structures/src Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -559,20 +559,28 @@ where
559559fn stable_hash_reduce < HCX , I , C , F > (
560560 hcx : & mut HCX ,
561561 hasher : & mut StableHasher ,
562- collection : C ,
562+ mut collection : C ,
563563 length : usize ,
564564 hash_function : F ,
565565) where
566566 C : Iterator < Item = I > ,
567567 F : Fn ( & mut StableHasher , & mut HCX , I ) ,
568568{
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) ) ;
576569 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+ }
578586}
You can’t perform that action at this time.
0 commit comments