Skip to content

Commit

Permalink
Remove useless bound checks from into_sorted_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiFire13 committed Nov 7, 2020
1 parent 25b3f61 commit 8d15753
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/alloc/src/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ impl<T: Ord> BinaryHeap<T> {
let mut end = self.len();
while end > 1 {
end -= 1;
self.data.swap(0, end);
unsafe {
let ptr = self.data.as_mut_ptr();
ptr::swap(ptr, ptr.add(end));
}
self.sift_down_range(0, end);
}
self.into_vec()
Expand Down

0 comments on commit 8d15753

Please sign in to comment.