Skip to content

Commit d36653f

Browse files
committed
Remove unused/redundant variables from Scheduler implementation (#27130)
Tidying up some redundant code left from previous iterations of the implementation DiffTrain build for [899cb95](899cb95)
1 parent 1cb6c1f commit d36653f

File tree

8 files changed

+280
-292
lines changed

8 files changed

+280
-292
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9f4fbec5f7bb639be6dac438f9da5f032ae12c15
1+
899cb95f52cc83ab5ca1eb1e268c909d3f0961e7

compiled/facebook-www/ReactDOM-profiling.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17364,7 +17364,7 @@ Internals.Events = [
1736417364
var devToolsConfig$jscomp$inline_1888 = {
1736517365
findFiberByHostInstance: getClosestInstanceFromNode,
1736617366
bundleType: 0,
17367-
version: "18.3.0-www-classic-121326e2",
17367+
version: "18.3.0-www-classic-d0943a52",
1736817368
rendererPackageName: "react-dom"
1736917369
};
1737017370
(function (internals) {
@@ -17408,7 +17408,7 @@ var devToolsConfig$jscomp$inline_1888 = {
1740817408
scheduleRoot: null,
1740917409
setRefreshHandler: null,
1741017410
getCurrentFiber: null,
17411-
reconcilerVersion: "18.3.0-www-classic-121326e2"
17411+
reconcilerVersion: "18.3.0-www-classic-d0943a52"
1741217412
});
1741317413
assign(Internals, {
1741417414
ReactBrowserEventEmitter: {
@@ -17623,7 +17623,7 @@ exports.unstable_renderSubtreeIntoContainer = function (
1762317623
);
1762417624
};
1762517625
exports.unstable_runWithPriority = runWithPriority;
17626-
exports.version = "18.3.0-www-classic-121326e2";
17626+
exports.version = "18.3.0-www-classic-d0943a52";
1762717627

1762817628
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
1762917629
if (

compiled/facebook-www/Scheduler-dev.classic.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ function handleTimeout(currentTime) {
344344
if (!isHostCallbackScheduled) {
345345
if (peek(taskQueue) !== null) {
346346
isHostCallbackScheduled = true;
347-
requestHostCallback(flushWork);
347+
requestHostCallback();
348348
} else {
349349
var firstTimer = peek(timerQueue);
350350

@@ -355,7 +355,7 @@ function handleTimeout(currentTime) {
355355
}
356356
}
357357

358-
function flushWork(hasTimeRemaining, initialTime) {
358+
function flushWork(initialTime) {
359359
if (enableProfiling) {
360360
markSchedulerUnsuspended(initialTime);
361361
} // We'll need a host callback the next time work is scheduled.
@@ -374,7 +374,7 @@ function flushWork(hasTimeRemaining, initialTime) {
374374
try {
375375
if (enableProfiling) {
376376
try {
377-
return workLoop(hasTimeRemaining, initialTime);
377+
return workLoop(initialTime);
378378
} catch (error) {
379379
if (currentTask !== null) {
380380
var currentTime = exports.unstable_now(); // $FlowFixMe[incompatible-call] found when upgrading Flow
@@ -388,7 +388,7 @@ function flushWork(hasTimeRemaining, initialTime) {
388388
}
389389
} else {
390390
// No catch in prod code path.
391-
return workLoop(hasTimeRemaining, initialTime);
391+
return workLoop(initialTime);
392392
}
393393
} finally {
394394
currentTask = null;
@@ -403,16 +403,13 @@ function flushWork(hasTimeRemaining, initialTime) {
403403
}
404404
}
405405

406-
function workLoop(hasTimeRemaining, initialTime) {
406+
function workLoop(initialTime) {
407407
var currentTime = initialTime;
408408
advanceTimers(currentTime);
409409
currentTask = peek(taskQueue);
410410

411411
while (currentTask !== null && !isSchedulerPaused) {
412-
if (
413-
currentTask.expirationTime > currentTime &&
414-
(!hasTimeRemaining || shouldYieldToHost())
415-
) {
412+
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
416413
// This currentTask hasn't expired, and we've reached the deadline.
417414
break;
418415
} // $FlowFixMe[incompatible-use] found when upgrading Flow
@@ -632,7 +629,7 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
632629

633630
if (!isHostCallbackScheduled && !isPerformingWork) {
634631
isHostCallbackScheduled = true;
635-
requestHostCallback(flushWork);
632+
requestHostCallback();
636633
}
637634
}
638635

@@ -648,7 +645,7 @@ function unstable_continueExecution() {
648645

649646
if (!isHostCallbackScheduled && !isPerformingWork) {
650647
isHostCallbackScheduled = true;
651-
requestHostCallback(flushWork);
648+
requestHostCallback();
652649
}
653650
}
654651

@@ -675,7 +672,6 @@ function unstable_getCurrentPriorityLevel() {
675672
}
676673

677674
var isMessageLoopRunning = false;
678-
var scheduledHostCallback = null;
679675
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
680676
// thread, like user events. By default, it yields multiple times per frame.
681677
// It does not attempt to align with frame boundaries, since most tasks don't
@@ -761,35 +757,30 @@ function forceFrameRate(fps) {
761757
}
762758

763759
var performWorkUntilDeadline = function () {
764-
if (scheduledHostCallback !== null) {
760+
if (isMessageLoopRunning) {
765761
var currentTime = exports.unstable_now(); // Keep track of the start time so we can measure how long the main thread
766762
// has been blocked.
767763

768-
startTime = currentTime;
769-
var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
764+
startTime = currentTime; // If a scheduler task throws, exit the current browser task so the
770765
// error can be observed.
771766
//
772767
// Intentionally not using a try-catch, since that makes some debugging
773-
// techniques harder. Instead, if `scheduledHostCallback` errors, then
774-
// `hasMoreWork` will remain true, and we'll continue the work loop.
768+
// techniques harder. Instead, if `flushWork` errors, then `hasMoreWork` will
769+
// remain true, and we'll continue the work loop.
775770

776771
var hasMoreWork = true;
777772

778773
try {
779-
// $FlowFixMe[not-a-function] found when upgrading Flow
780-
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
774+
hasMoreWork = flushWork(currentTime);
781775
} finally {
782776
if (hasMoreWork) {
783777
// If there's more work, schedule the next message event at the end
784778
// of the preceding one.
785779
schedulePerformWorkUntilDeadline();
786780
} else {
787781
isMessageLoopRunning = false;
788-
scheduledHostCallback = null;
789782
}
790783
}
791-
} else {
792-
isMessageLoopRunning = false;
793784
} // Yielding to the browser will give it a chance to paint, so we can
794785
// reset this.
795786

@@ -832,8 +823,6 @@ if (typeof localSetImmediate === "function") {
832823
}
833824

834825
function requestHostCallback(callback) {
835-
scheduledHostCallback = callback;
836-
837826
if (!isMessageLoopRunning) {
838827
isMessageLoopRunning = true;
839828
schedulePerformWorkUntilDeadline();

compiled/facebook-www/Scheduler-dev.modern.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ function handleTimeout(currentTime) {
344344
if (!isHostCallbackScheduled) {
345345
if (peek(taskQueue) !== null) {
346346
isHostCallbackScheduled = true;
347-
requestHostCallback(flushWork);
347+
requestHostCallback();
348348
} else {
349349
var firstTimer = peek(timerQueue);
350350

@@ -355,7 +355,7 @@ function handleTimeout(currentTime) {
355355
}
356356
}
357357

358-
function flushWork(hasTimeRemaining, initialTime) {
358+
function flushWork(initialTime) {
359359
if (enableProfiling) {
360360
markSchedulerUnsuspended(initialTime);
361361
} // We'll need a host callback the next time work is scheduled.
@@ -374,7 +374,7 @@ function flushWork(hasTimeRemaining, initialTime) {
374374
try {
375375
if (enableProfiling) {
376376
try {
377-
return workLoop(hasTimeRemaining, initialTime);
377+
return workLoop(initialTime);
378378
} catch (error) {
379379
if (currentTask !== null) {
380380
var currentTime = exports.unstable_now(); // $FlowFixMe[incompatible-call] found when upgrading Flow
@@ -388,7 +388,7 @@ function flushWork(hasTimeRemaining, initialTime) {
388388
}
389389
} else {
390390
// No catch in prod code path.
391-
return workLoop(hasTimeRemaining, initialTime);
391+
return workLoop(initialTime);
392392
}
393393
} finally {
394394
currentTask = null;
@@ -403,16 +403,13 @@ function flushWork(hasTimeRemaining, initialTime) {
403403
}
404404
}
405405

406-
function workLoop(hasTimeRemaining, initialTime) {
406+
function workLoop(initialTime) {
407407
var currentTime = initialTime;
408408
advanceTimers(currentTime);
409409
currentTask = peek(taskQueue);
410410

411411
while (currentTask !== null && !isSchedulerPaused) {
412-
if (
413-
currentTask.expirationTime > currentTime &&
414-
(!hasTimeRemaining || shouldYieldToHost())
415-
) {
412+
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
416413
// This currentTask hasn't expired, and we've reached the deadline.
417414
break;
418415
} // $FlowFixMe[incompatible-use] found when upgrading Flow
@@ -632,7 +629,7 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
632629

633630
if (!isHostCallbackScheduled && !isPerformingWork) {
634631
isHostCallbackScheduled = true;
635-
requestHostCallback(flushWork);
632+
requestHostCallback();
636633
}
637634
}
638635

@@ -648,7 +645,7 @@ function unstable_continueExecution() {
648645

649646
if (!isHostCallbackScheduled && !isPerformingWork) {
650647
isHostCallbackScheduled = true;
651-
requestHostCallback(flushWork);
648+
requestHostCallback();
652649
}
653650
}
654651

@@ -675,7 +672,6 @@ function unstable_getCurrentPriorityLevel() {
675672
}
676673

677674
var isMessageLoopRunning = false;
678-
var scheduledHostCallback = null;
679675
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
680676
// thread, like user events. By default, it yields multiple times per frame.
681677
// It does not attempt to align with frame boundaries, since most tasks don't
@@ -761,35 +757,30 @@ function forceFrameRate(fps) {
761757
}
762758

763759
var performWorkUntilDeadline = function () {
764-
if (scheduledHostCallback !== null) {
760+
if (isMessageLoopRunning) {
765761
var currentTime = exports.unstable_now(); // Keep track of the start time so we can measure how long the main thread
766762
// has been blocked.
767763

768-
startTime = currentTime;
769-
var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
764+
startTime = currentTime; // If a scheduler task throws, exit the current browser task so the
770765
// error can be observed.
771766
//
772767
// Intentionally not using a try-catch, since that makes some debugging
773-
// techniques harder. Instead, if `scheduledHostCallback` errors, then
774-
// `hasMoreWork` will remain true, and we'll continue the work loop.
768+
// techniques harder. Instead, if `flushWork` errors, then `hasMoreWork` will
769+
// remain true, and we'll continue the work loop.
775770

776771
var hasMoreWork = true;
777772

778773
try {
779-
// $FlowFixMe[not-a-function] found when upgrading Flow
780-
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
774+
hasMoreWork = flushWork(currentTime);
781775
} finally {
782776
if (hasMoreWork) {
783777
// If there's more work, schedule the next message event at the end
784778
// of the preceding one.
785779
schedulePerformWorkUntilDeadline();
786780
} else {
787781
isMessageLoopRunning = false;
788-
scheduledHostCallback = null;
789782
}
790783
}
791-
} else {
792-
isMessageLoopRunning = false;
793784
} // Yielding to the browser will give it a chance to paint, so we can
794785
// reset this.
795786

@@ -832,8 +823,6 @@ if (typeof localSetImmediate === "function") {
832823
}
833824

834825
function requestHostCallback(callback) {
835-
scheduledHostCallback = callback;
836-
837826
if (!isMessageLoopRunning) {
838827
isMessageLoopRunning = true;
839828
schedulePerformWorkUntilDeadline();

0 commit comments

Comments
 (0)