Skip to content

Commit 873ae21

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 commit 899cb95.
1 parent 5199045 commit 873ae21

File tree

10 files changed

+152
-159
lines changed

10 files changed

+152
-159
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23982,7 +23982,7 @@ function createFiberRoot(
2398223982
return root;
2398323983
}
2398423984

23985-
var ReactVersion = "18.3.0-canary-d445cee60-20230718";
23985+
var ReactVersion = "18.3.0-canary-899cb95f5-20230719";
2398623986

2398723987
// Might add PROFILE later.
2398823988

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8630,7 +8630,7 @@ var devToolsConfig$jscomp$inline_1032 = {
86308630
throw Error("TestRenderer does not support findFiberByHostInstance()");
86318631
},
86328632
bundleType: 0,
8633-
version: "18.3.0-canary-d445cee60-20230718",
8633+
version: "18.3.0-canary-899cb95f5-20230719",
86348634
rendererPackageName: "react-test-renderer"
86358635
};
86368636
var internals$jscomp$inline_1231 = {
@@ -8661,7 +8661,7 @@ var internals$jscomp$inline_1231 = {
86618661
scheduleRoot: null,
86628662
setRefreshHandler: null,
86638663
getCurrentFiber: null,
8664-
reconcilerVersion: "18.3.0-canary-d445cee60-20230718"
8664+
reconcilerVersion: "18.3.0-canary-899cb95f5-20230719"
86658665
};
86668666
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
86678667
var hook$jscomp$inline_1232 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9056,7 +9056,7 @@ var devToolsConfig$jscomp$inline_1074 = {
90569056
throw Error("TestRenderer does not support findFiberByHostInstance()");
90579057
},
90589058
bundleType: 0,
9059-
version: "18.3.0-canary-d445cee60-20230718",
9059+
version: "18.3.0-canary-899cb95f5-20230719",
90609060
rendererPackageName: "react-test-renderer"
90619061
};
90629062
var internals$jscomp$inline_1272 = {
@@ -9087,7 +9087,7 @@ var internals$jscomp$inline_1272 = {
90879087
scheduleRoot: null,
90889088
setRefreshHandler: null,
90899089
getCurrentFiber: null,
9090-
reconcilerVersion: "18.3.0-canary-d445cee60-20230718"
9090+
reconcilerVersion: "18.3.0-canary-899cb95f5-20230719"
90919091
};
90929092
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
90939093
var hook$jscomp$inline_1273 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-canary-d445cee60-20230718";
30+
var ReactVersion = "18.3.0-canary-899cb95f5-20230719";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
616616
exports.useTransition = function () {
617617
return ReactCurrentDispatcher.current.useTransition();
618618
};
619-
exports.version = "18.3.0-canary-d445cee60-20230718";
619+
exports.version = "18.3.0-canary-899cb95f5-20230719";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
619619
exports.useTransition = function () {
620620
return ReactCurrentDispatcher.current.useTransition();
621621
};
622-
exports.version = "18.3.0-canary-d445cee60-20230718";
622+
exports.version = "18.3.0-canary-899cb95f5-20230719";
623623

624624
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
625625
if (

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/scheduler/cjs/Scheduler-dev.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b85c2a10b2dc93deb1fb229aeda66768>>
10+
* @generated SignedSource<<bf6139f486580812339baacd8463bb4a>>
1111
*/
1212

1313
'use strict';
@@ -205,7 +205,7 @@ function handleTimeout(currentTime) {
205205
if (!isHostCallbackScheduled) {
206206
if (peek(taskQueue) !== null) {
207207
isHostCallbackScheduled = true;
208-
requestHostCallback(flushWork);
208+
requestHostCallback();
209209
} else {
210210
var firstTimer = peek(timerQueue);
211211

@@ -216,7 +216,7 @@ function handleTimeout(currentTime) {
216216
}
217217
}
218218

219-
function flushWork(hasTimeRemaining, initialTime) {
219+
function flushWork(initialTime) {
220220
isHostCallbackScheduled = false;
221221

222222
if (isHostTimeoutScheduled) {
@@ -233,7 +233,7 @@ function flushWork(hasTimeRemaining, initialTime) {
233233
if (enableProfiling);
234234
else {
235235
// No catch in prod code path.
236-
return workLoop(hasTimeRemaining, initialTime);
236+
return workLoop(initialTime);
237237
}
238238
} finally {
239239
currentTask = null;
@@ -242,16 +242,13 @@ function flushWork(hasTimeRemaining, initialTime) {
242242
}
243243
}
244244

245-
function workLoop(hasTimeRemaining, initialTime) {
245+
function workLoop(initialTime) {
246246
var currentTime = initialTime;
247247
advanceTimers(currentTime);
248248
currentTask = peek(taskQueue);
249249

250250
while (currentTask !== null && !enableSchedulerDebugging) {
251-
if (
252-
currentTask.expirationTime > currentTime &&
253-
(!hasTimeRemaining || shouldYieldToHost())
254-
) {
251+
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
255252
// This currentTask hasn't expired, and we've reached the deadline.
256253
break;
257254
} // $FlowFixMe[incompatible-use] found when upgrading Flow
@@ -445,7 +442,7 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
445442

446443
if (!isHostCallbackScheduled && !isPerformingWork) {
447444
isHostCallbackScheduled = true;
448-
requestHostCallback(flushWork);
445+
requestHostCallback();
449446
}
450447
}
451448

@@ -457,7 +454,7 @@ function unstable_pauseExecution() {}
457454
function unstable_continueExecution() {
458455
if (!isHostCallbackScheduled && !isPerformingWork) {
459456
isHostCallbackScheduled = true;
460-
requestHostCallback(flushWork);
457+
requestHostCallback();
461458
}
462459
}
463460

@@ -477,7 +474,6 @@ function unstable_getCurrentPriorityLevel() {
477474
}
478475

479476
var isMessageLoopRunning = false;
480-
var scheduledHostCallback = null;
481477
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
482478
// thread, like user events. By default, it yields multiple times per frame.
483479
// It does not attempt to align with frame boundaries, since most tasks don't
@@ -519,35 +515,30 @@ function forceFrameRate(fps) {
519515
}
520516

521517
var performWorkUntilDeadline = function () {
522-
if (scheduledHostCallback !== null) {
518+
if (isMessageLoopRunning) {
523519
var currentTime = exports.unstable_now(); // Keep track of the start time so we can measure how long the main thread
524520
// has been blocked.
525521

526-
startTime = currentTime;
527-
var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
522+
startTime = currentTime; // If a scheduler task throws, exit the current browser task so the
528523
// error can be observed.
529524
//
530525
// Intentionally not using a try-catch, since that makes some debugging
531-
// techniques harder. Instead, if `scheduledHostCallback` errors, then
532-
// `hasMoreWork` will remain true, and we'll continue the work loop.
526+
// techniques harder. Instead, if `flushWork` errors, then `hasMoreWork` will
527+
// remain true, and we'll continue the work loop.
533528

534529
var hasMoreWork = true;
535530

536531
try {
537-
// $FlowFixMe[not-a-function] found when upgrading Flow
538-
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
532+
hasMoreWork = flushWork(currentTime);
539533
} finally {
540534
if (hasMoreWork) {
541535
// If there's more work, schedule the next message event at the end
542536
// of the preceding one.
543537
schedulePerformWorkUntilDeadline();
544538
} else {
545539
isMessageLoopRunning = false;
546-
scheduledHostCallback = null;
547540
}
548541
}
549-
} else {
550-
isMessageLoopRunning = false;
551542
} // Yielding to the browser will give it a chance to paint, so we can
552543
};
553544

@@ -587,8 +578,6 @@ if (typeof localSetImmediate === "function") {
587578
}
588579

589580
function requestHostCallback(callback) {
590-
scheduledHostCallback = callback;
591-
592581
if (!isMessageLoopRunning) {
593582
isMessageLoopRunning = true;
594583
schedulePerformWorkUntilDeadline();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/scheduler/cjs/Scheduler-prod.js

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<6de9b4c616b4fa4d342cccd7689eb2af>>
10+
* @generated SignedSource<<cd7ed3a069445a95189053c07769d208>>
1111
*/
1212

1313
"use strict";
@@ -104,86 +104,89 @@ function handleTimeout(currentTime) {
104104
advanceTimers(currentTime);
105105
if (!isHostCallbackScheduled)
106106
if (null !== peek(taskQueue))
107-
(isHostCallbackScheduled = !0), requestHostCallback(flushWork);
107+
(isHostCallbackScheduled = !0), requestHostCallback();
108108
else {
109109
var firstTimer = peek(timerQueue);
110110
null !== firstTimer &&
111111
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
112112
}
113113
}
114-
function flushWork(hasTimeRemaining, initialTime) {
115-
isHostCallbackScheduled = !1;
116-
isHostTimeoutScheduled &&
117-
((isHostTimeoutScheduled = !1),
118-
localClearTimeout(taskTimeoutID),
119-
(taskTimeoutID = -1));
120-
isPerformingWork = !0;
121-
var previousPriorityLevel = currentPriorityLevel;
122-
try {
123-
a: {
124-
advanceTimers(initialTime);
125-
for (
126-
currentTask = peek(taskQueue);
127-
null !== currentTask &&
128-
(!(currentTask.expirationTime > initialTime) ||
129-
(hasTimeRemaining && !shouldYieldToHost()));
130-
131-
) {
132-
var callback = currentTask.callback;
133-
if ("function" === typeof callback) {
134-
currentTask.callback = null;
135-
currentPriorityLevel = currentTask.priorityLevel;
136-
var continuationCallback = callback(
137-
currentTask.expirationTime <= initialTime
138-
);
139-
initialTime = exports.unstable_now();
140-
if ("function" === typeof continuationCallback) {
141-
currentTask.callback = continuationCallback;
142-
advanceTimers(initialTime);
143-
var JSCompiler_inline_result = !0;
144-
break a;
145-
} else
146-
currentTask === peek(taskQueue) && pop(taskQueue),
147-
advanceTimers(initialTime);
148-
} else pop(taskQueue);
149-
currentTask = peek(taskQueue);
150-
}
151-
if (null !== currentTask) JSCompiler_inline_result = !0;
152-
else {
153-
var firstTimer = peek(timerQueue);
154-
null !== firstTimer &&
155-
requestHostTimeout(handleTimeout, firstTimer.startTime - initialTime);
156-
JSCompiler_inline_result = !1;
157-
}
158-
}
159-
return JSCompiler_inline_result;
160-
} finally {
161-
(currentTask = null),
162-
(currentPriorityLevel = previousPriorityLevel),
163-
(isPerformingWork = !1);
164-
}
165-
}
166114
var isMessageLoopRunning = !1,
167-
scheduledHostCallback = null,
168115
taskTimeoutID = -1,
169116
frameInterval = 5,
170117
startTime = -1;
171118
function shouldYieldToHost() {
172119
return exports.unstable_now() - startTime < frameInterval ? !1 : !0;
173120
}
174121
function performWorkUntilDeadline() {
175-
if (null !== scheduledHostCallback) {
122+
if (isMessageLoopRunning) {
176123
var currentTime = exports.unstable_now();
177124
startTime = currentTime;
178125
var hasMoreWork = !0;
179126
try {
180-
hasMoreWork = scheduledHostCallback(!0, currentTime);
127+
a: {
128+
isHostCallbackScheduled = !1;
129+
isHostTimeoutScheduled &&
130+
((isHostTimeoutScheduled = !1),
131+
localClearTimeout(taskTimeoutID),
132+
(taskTimeoutID = -1));
133+
isPerformingWork = !0;
134+
var previousPriorityLevel = currentPriorityLevel;
135+
try {
136+
b: {
137+
advanceTimers(currentTime);
138+
for (
139+
currentTask = peek(taskQueue);
140+
null !== currentTask &&
141+
!(
142+
currentTask.expirationTime > currentTime && shouldYieldToHost()
143+
);
144+
145+
) {
146+
var callback = currentTask.callback;
147+
if ("function" === typeof callback) {
148+
currentTask.callback = null;
149+
currentPriorityLevel = currentTask.priorityLevel;
150+
var continuationCallback = callback(
151+
currentTask.expirationTime <= currentTime
152+
);
153+
currentTime = exports.unstable_now();
154+
if ("function" === typeof continuationCallback) {
155+
currentTask.callback = continuationCallback;
156+
advanceTimers(currentTime);
157+
hasMoreWork = !0;
158+
break b;
159+
}
160+
currentTask === peek(taskQueue) && pop(taskQueue);
161+
advanceTimers(currentTime);
162+
} else pop(taskQueue);
163+
currentTask = peek(taskQueue);
164+
}
165+
if (null !== currentTask) hasMoreWork = !0;
166+
else {
167+
var firstTimer = peek(timerQueue);
168+
null !== firstTimer &&
169+
requestHostTimeout(
170+
handleTimeout,
171+
firstTimer.startTime - currentTime
172+
);
173+
hasMoreWork = !1;
174+
}
175+
}
176+
break a;
177+
} finally {
178+
(currentTask = null),
179+
(currentPriorityLevel = previousPriorityLevel),
180+
(isPerformingWork = !1);
181+
}
182+
hasMoreWork = void 0;
183+
}
181184
} finally {
182185
hasMoreWork
183186
? schedulePerformWorkUntilDeadline()
184-
: ((isMessageLoopRunning = !1), (scheduledHostCallback = null));
187+
: (isMessageLoopRunning = !1);
185188
}
186-
} else isMessageLoopRunning = !1;
189+
}
187190
}
188191
var schedulePerformWorkUntilDeadline;
189192
if ("function" === typeof localSetImmediate)
@@ -201,8 +204,7 @@ else if ("undefined" !== typeof MessageChannel) {
201204
schedulePerformWorkUntilDeadline = function () {
202205
localSetTimeout(performWorkUntilDeadline, 0);
203206
};
204-
function requestHostCallback(callback) {
205-
scheduledHostCallback = callback;
207+
function requestHostCallback() {
206208
isMessageLoopRunning ||
207209
((isMessageLoopRunning = !0), schedulePerformWorkUntilDeadline());
208210
}
@@ -223,7 +225,7 @@ exports.unstable_cancelCallback = function (task) {
223225
exports.unstable_continueExecution = function () {
224226
isHostCallbackScheduled ||
225227
isPerformingWork ||
226-
((isHostCallbackScheduled = !0), requestHostCallback(flushWork));
228+
((isHostCallbackScheduled = !0), requestHostCallback());
227229
};
228230
exports.unstable_forceFrameRate = function (fps) {
229231
0 > fps || 125 < fps
@@ -328,7 +330,7 @@ exports.unstable_scheduleCallback = function (
328330
push(taskQueue, priorityLevel),
329331
isHostCallbackScheduled ||
330332
isPerformingWork ||
331-
((isHostCallbackScheduled = !0), requestHostCallback(flushWork)));
333+
((isHostCallbackScheduled = !0), requestHostCallback()));
332334
return priorityLevel;
333335
};
334336
exports.unstable_shouldYield = shouldYieldToHost;

0 commit comments

Comments
 (0)