File tree Expand file tree Collapse file tree 2 files changed +2
-8
lines changed
compiler/rustc_metadata/src/rmeta Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -647,10 +647,7 @@ impl<'tcx> MetadataBlob {
647647 crate fn get_root ( & self ) -> CrateRoot < ' tcx > {
648648 let slice = & self . blob ( ) [ ..] ;
649649 let offset = METADATA_HEADER . len ( ) ;
650- let pos = ( ( ( slice[ offset + 0 ] as u32 ) << 24 )
651- | ( ( slice[ offset + 1 ] as u32 ) << 16 )
652- | ( ( slice[ offset + 2 ] as u32 ) << 8 )
653- | ( ( slice[ offset + 3 ] as u32 ) << 0 ) ) as usize ;
650+ let pos = ( u32:: from_le_bytes ( slice[ offset..offset + 4 ] . try_into ( ) . unwrap ( ) ) ) as usize ;
654651 Lazy :: < CrateRoot < ' tcx > > :: from_position ( NonZeroUsize :: new ( pos) . unwrap ( ) ) . decode ( self )
655652 }
656653
Original file line number Diff line number Diff line change @@ -2214,10 +2214,7 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
22142214 // Encode the root position.
22152215 let header = METADATA_HEADER . len ( ) ;
22162216 let pos = root. position . get ( ) ;
2217- result[ header + 0 ] = ( pos >> 24 ) as u8 ;
2218- result[ header + 1 ] = ( pos >> 16 ) as u8 ;
2219- result[ header + 2 ] = ( pos >> 8 ) as u8 ;
2220- result[ header + 3 ] = ( pos >> 0 ) as u8 ;
2217+ result[ header..header + 4 ] . copy_from_slice ( & pos. to_le_bytes ( ) ) ;
22212218
22222219 // Record metadata size for self-profiling
22232220 tcx. prof . artifact_size ( "crate_metadata" , "crate_metadata" , result. len ( ) as u64 ) ;
You can’t perform that action at this time.
0 commit comments