Skip to content

Commit f2318c1

Browse files
committed
Sophie nits
1 parent 220ba25 commit f2318c1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/scheduler/src/SchedulerMinHeap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function pop(heap: Heap): Node | null {
2828
const first = heap[0];
2929
if (first !== undefined) {
3030
const last = heap.pop();
31-
if (last !== undefined && last !== first) {
31+
if (last !== first) {
3232
heap[0] = last;
3333
siftDown(heap, last, 0);
3434
}
@@ -39,8 +39,8 @@ export function pop(heap: Heap): Node | null {
3939
}
4040

4141
function siftUp(heap, node, index) {
42-
while (index > 0) {
43-
const parentIndex = Math.floor((index + 1) / 2) - 1;
42+
while (true) {
43+
const parentIndex = Math.floor((index - 1) / 2);
4444
const parent = heap[parentIndex];
4545
if (parent !== undefined && compare(parent, node) > 0) {
4646
// The parent is larger. Swap positions.

0 commit comments

Comments
 (0)