@@ -250,6 +250,7 @@ where
250
250
let mut offsets_l = [ MaybeUninit :: < u8 > :: uninit ( ) ; BLOCK ] ;
251
251
252
252
// The current block on the right side (from `r.sub(block_r)` to `r`).
253
+ // SAFETY: The documentation for .add() specifically mention that `vec.as_ptr().add(vec.len())` is always safe`
253
254
let mut r = unsafe { l. add ( v. len ( ) ) } ;
254
255
let mut block_r = BLOCK ;
255
256
let mut start_r = ptr:: null_mut ( ) ;
@@ -435,12 +436,14 @@ where
435
436
let mut l = 0 ;
436
437
let mut r = v. len ( ) ;
437
438
unsafe {
438
- // Find the first element greater then or equal to the pivot.
439
+ // Find the first element greater than or equal to the pivot.
440
+ // SAFETY: We already do the bound checking here with `l<r`.
439
441
while l < r && is_less ( v. get_unchecked ( l) , pivot) {
440
442
l += 1 ;
441
443
}
442
444
443
445
// Find the last element smaller that the pivot.
446
+ // SAFETY: The minimum value for `l` is 0 and the maximum value for `r` is `v.len().`
444
447
while l < r && !is_less ( v. get_unchecked ( r - 1 ) , pivot) {
445
448
r -= 1 ;
446
449
}
@@ -483,12 +486,14 @@ where
483
486
let mut r = v. len ( ) ;
484
487
loop {
485
488
unsafe {
486
- // Find the first element greater that the pivot.
489
+ // Find the first element greater than the pivot.
490
+ // SAFETY: We already do the bound checking here with `l<r`
487
491
while l < r && !is_less ( pivot, v. get_unchecked ( l) ) {
488
492
l += 1 ;
489
493
}
490
494
491
495
// Find the last element equal to the pivot.
496
+ // SAFETY: The minimum value for `l` is 0 and the maximum value for `r` is `v.len().`
492
497
while l < r && is_less ( pivot, v. get_unchecked ( r - 1 ) ) {
493
498
r -= 1 ;
494
499
}
0 commit comments