efebe45cc0
collections: Make BinaryHeap panic safe in sift_up / sift_down Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. NOTE: The BinaryHeap will still be inconsistent after a comparison fails. It will not have the heap property. What we fix is just that elements will be valid values. This is actually a performance win -- the new code does not bother to write in `zeroed()` values in the holes, it just leaves them as they were. Net result is something like a 5% decrease in runtime for `BinaryHeap::from_vec`. This can be further improved by using unchecked indexing (I confirmed it makes a difference, not a surprise with the non-sequential access going on), but let's leave that for another PR. Safety first 😉 Fixes #25842 |
||
---|---|---|
.. | ||
auxiliary | ||
bench | ||
codegen | ||
compile-fail | ||
compile-fail-fulldeps | ||
debuginfo | ||
parse-fail | ||
pretty | ||
run-fail | ||
run-fail-fulldeps | ||
run-make | ||
run-pass | ||
run-pass-fulldeps | ||
run-pass-valgrind | ||
rustdoc |