Skip to content

Commit 4a7dbbc

Browse files
committed
Remove redundant scheduleHostCallback
This is always `flushWork` so we can just call that directly.
1 parent e923b5e commit 4a7dbbc

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

packages/scheduler/src/forks/Scheduler.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,6 @@ function unstable_getCurrentPriorityLevel(): PriorityLevel {
462462
}
463463

464464
let isMessageLoopRunning = false;
465-
let scheduledHostCallback:
466-
| null
467-
| ((initialTime: DOMHighResTimeStamp | number) => boolean) = null;
468465
let taskTimeoutID: TimeoutID = (-1: any);
469466

470467
// Scheduler periodically yields in case there is other work on the main
@@ -556,7 +553,7 @@ function forceFrameRate(fps: number) {
556553
}
557554

558555
const performWorkUntilDeadline = () => {
559-
if (scheduledHostCallback !== null) {
556+
if (isMessageLoopRunning) {
560557
const currentTime = getCurrentTime();
561558
// Keep track of the start time so we can measure how long the main thread
562559
// has been blocked.
@@ -566,24 +563,20 @@ const performWorkUntilDeadline = () => {
566563
// error can be observed.
567564
//
568565
// Intentionally not using a try-catch, since that makes some debugging
569-
// techniques harder. Instead, if `scheduledHostCallback` errors, then
570-
// `hasMoreWork` will remain true, and we'll continue the work loop.
566+
// techniques harder. Instead, if `flushWork` errors, then `hasMoreWork` will
567+
// remain true, and we'll continue the work loop.
571568
let hasMoreWork = true;
572569
try {
573-
// $FlowFixMe[not-a-function] found when upgrading Flow
574-
hasMoreWork = scheduledHostCallback(currentTime);
570+
hasMoreWork = flushWork(currentTime);
575571
} finally {
576572
if (hasMoreWork) {
577573
// If there's more work, schedule the next message event at the end
578574
// of the preceding one.
579575
schedulePerformWorkUntilDeadline();
580576
} else {
581577
isMessageLoopRunning = false;
582-
scheduledHostCallback = null;
583578
}
584579
}
585-
} else {
586-
isMessageLoopRunning = false;
587580
}
588581
// Yielding to the browser will give it a chance to paint, so we can
589582
// reset this.
@@ -624,7 +617,6 @@ if (typeof localSetImmediate === 'function') {
624617
}
625618

626619
function requestHostCallback(callback: (initialTime: number) => boolean) {
627-
scheduledHostCallback = callback;
628620
if (!isMessageLoopRunning) {
629621
isMessageLoopRunning = true;
630622
schedulePerformWorkUntilDeadline();

0 commit comments

Comments
 (0)