File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
library/alloc/src/collections/btree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1608,15 +1608,19 @@ pub mod marker {
16081608
16091609unsafe fn slice_insert < T > ( slice : & mut [ T ] , idx : usize , val : T ) {
16101610 unsafe {
1611- ptr:: copy ( slice. as_ptr ( ) . add ( idx) , slice. as_mut_ptr ( ) . add ( idx + 1 ) , slice. len ( ) - idx) ;
1612- ptr:: write ( slice. get_unchecked_mut ( idx) , val) ;
1611+ let len = slice. len ( ) ;
1612+ let slice_ptr = slice. as_mut_ptr ( ) ;
1613+ ptr:: copy ( slice_ptr. add ( idx) , slice_ptr. add ( idx + 1 ) , len - idx) ;
1614+ ptr:: write ( slice_ptr. add ( idx) , val) ;
16131615 }
16141616}
16151617
16161618unsafe fn slice_remove < T > ( slice : & mut [ T ] , idx : usize ) -> T {
16171619 unsafe {
1618- let ret = ptr:: read ( slice. get_unchecked ( idx) ) ;
1619- ptr:: copy ( slice. as_ptr ( ) . add ( idx + 1 ) , slice. as_mut_ptr ( ) . add ( idx) , slice. len ( ) - idx - 1 ) ;
1620+ let len = slice. len ( ) ;
1621+ let slice_ptr = slice. as_mut_ptr ( ) ;
1622+ let ret = ptr:: read ( slice_ptr. add ( idx) ) ;
1623+ ptr:: copy ( slice_ptr. add ( idx + 1 ) , slice_ptr. add ( idx) , len - idx - 1 ) ;
16201624 ret
16211625 }
16221626}
You can’t perform that action at this time.
0 commit comments