We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 220ba25 commit f2318c1Copy full SHA for f2318c1
packages/scheduler/src/SchedulerMinHeap.js
@@ -28,7 +28,7 @@ export function pop(heap: Heap): Node | null {
28
const first = heap[0];
29
if (first !== undefined) {
30
const last = heap.pop();
31
- if (last !== undefined && last !== first) {
+ if (last !== first) {
32
heap[0] = last;
33
siftDown(heap, last, 0);
34
}
@@ -39,8 +39,8 @@ export function pop(heap: Heap): Node | null {
39
40
41
function siftUp(heap, node, index) {
42
- while (index > 0) {
43
- const parentIndex = Math.floor((index + 1) / 2) - 1;
+ while (true) {
+ const parentIndex = Math.floor((index - 1) / 2);
44
const parent = heap[parentIndex];
45
if (parent !== undefined && compare(parent, node) > 0) {
46
// The parent is larger. Swap positions.
0 commit comments