File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -1571,19 +1571,18 @@ impl PathBuf {
15711571 Some ( f) => f. as_encoded_bytes ( ) ,
15721572 } ;
15731573
1574- let new = extension. as_encoded_bytes ( ) ;
1574+ let new = extension;
15751575 if !new. is_empty ( ) {
15761576 // truncate until right after the file name
15771577 // this is necessary for trimming the trailing slash
15781578 let end_file_name = file_name[ file_name. len ( ) ..] . as_ptr ( ) . addr ( ) ;
15791579 let start = self . inner . as_encoded_bytes ( ) . as_ptr ( ) . addr ( ) ;
1580- let v = self . as_mut_vec ( ) ;
1581- v. truncate ( end_file_name. wrapping_sub ( start) ) ;
1580+ self . inner . truncate ( end_file_name. wrapping_sub ( start) ) ;
15821581
15831582 // append the new extension
1584- v . reserve_exact ( new. len ( ) + 1 ) ;
1585- v . push ( b'.' ) ;
1586- v . extend_from_slice ( new) ;
1583+ self . inner . reserve_exact ( new. len ( ) + 1 ) ;
1584+ self . inner . push ( OsStr :: new ( "." ) ) ;
1585+ self . inner . push ( new) ;
15871586 }
15881587
15891588 true
You can’t perform that action at this time.
0 commit comments