Commit ec8ae4b
committed
Auto merge of #29811 - bluss:binary-heap-sift-less, r=gankro
BinaryHeap: Simplify sift down
Sift down was doing all too much work: it can stop directly when the
current element obeys the heap property in relation to its children.
In the old code, sift down didn't compare the element to sift down at
all, so it was maximally sifted down and relied on the sift up call to
put it in the correct location.
This should speed up heapify and .pop().
Also rename Hole::removed() to Hole::element()1 file changed
+8
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
| 525 | + | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
532 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
533 | 534 | | |
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
537 | 538 | | |
| 539 | + | |
538 | 540 | | |
539 | 541 | | |
540 | 542 | | |
| 543 | + | |
| 544 | + | |
541 | 545 | | |
542 | 546 | | |
543 | 547 | | |
544 | | - | |
545 | | - | |
546 | 548 | | |
547 | | - | |
548 | 549 | | |
549 | 550 | | |
550 | 551 | | |
| |||
606 | 607 | | |
607 | 608 | | |
608 | 609 | | |
609 | | - | |
| 610 | + | |
610 | 611 | | |
611 | 612 | | |
612 | 613 | | |
| |||
0 commit comments