Skip to content

Commit 8d15753

Browse files
committed
Remove useless bound checks from into_sorted_vec
1 parent 25b3f61 commit 8d15753

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/alloc/src/collections/binary_heap.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,10 @@ impl<T: Ord> BinaryHeap<T> {
495495
let mut end = self.len();
496496
while end > 1 {
497497
end -= 1;
498-
self.data.swap(0, end);
498+
unsafe {
499+
let ptr = self.data.as_mut_ptr();
500+
ptr::swap(ptr, ptr.add(end));
501+
}
499502
self.sift_down_range(0, end);
500503
}
501504
self.into_vec()

0 commit comments

Comments
 (0)