Skip to content

Commit a9e9d14

Browse files
committed
Remove unnecessary work loop variables
Since we no longer support SuspenseConfig options, we don't need to track these values.
1 parent ada4541 commit a9e9d14

7 files changed

Lines changed: 9 additions & 100 deletions

File tree

packages/react-reconciler/src/ReactFiberHooks.new.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import {
6363
warnIfNotCurrentlyActingEffectsInDEV,
6464
warnIfNotCurrentlyActingUpdatesInDev,
6565
warnIfNotScopedWithMatchingAct,
66-
markRenderEventTimeAndConfig,
6766
markSkippedUpdateLanes,
6867
} from './ReactFiberWorkLoop.new';
6968

@@ -764,14 +763,6 @@ function updateReducer<S, I, A>(
764763
newBaseQueueLast = newBaseQueueLast.next = clone;
765764
}
766765

767-
// Mark the event time of this update as relevant to this render pass.
768-
// TODO: This should ideally use the true event time of this update rather than
769-
// its priority which is a derived and not reverseable value.
770-
// TODO: We should skip this update if it was already committed but currently
771-
// we have no way of detecting the difference between a committed and suspended
772-
// update here.
773-
markRenderEventTimeAndConfig(updateEventTime, suspenseConfig);
774-
775766
// Process this update.
776767
if (update.eagerReducer === reducer) {
777768
// If this update was processed eagerly, and its reducer matches the

packages/react-reconciler/src/ReactFiberHooks.old.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import {
6262
warnIfNotCurrentlyActingEffectsInDEV,
6363
warnIfNotCurrentlyActingUpdatesInDev,
6464
warnIfNotScopedWithMatchingAct,
65-
markRenderEventTimeAndConfig,
6665
markSkippedUpdateLanes,
6766
} from './ReactFiberWorkLoop.old';
6867

@@ -763,14 +762,6 @@ function updateReducer<S, I, A>(
763762
newBaseQueueLast = newBaseQueueLast.next = clone;
764763
}
765764

766-
// Mark the event time of this update as relevant to this render pass.
767-
// TODO: This should ideally use the true event time of this update rather than
768-
// its priority which is a derived and not reversible value.
769-
// TODO: We should skip this update if it was already committed but currently
770-
// we have no way of detecting the difference between a committed and suspended
771-
// update here.
772-
markRenderEventTimeAndConfig(updateEventTime, suspenseConfig);
773-
774765
// Process this update.
775766
if (update.eagerReducer === reducer) {
776767
// If this update was processed eagerly, and its reducer matches the

packages/react-reconciler/src/ReactFiberLane.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ export function includesNonIdleWork(lanes: Lanes) {
461461
export function includesOnlyRetries(lanes: Lanes) {
462462
return (lanes & RetryLanes) === lanes;
463463
}
464+
export function includesOnlyTransitions(lanes: Lanes) {
465+
return (lanes & TransitionLanes) === lanes;
466+
}
464467

465468
// To ensure consistency across multiple updates in the same event, this should
466469
// be a pure function, so that it always returns the same lane for given inputs.

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ import {
171171
hasDiscreteLanes,
172172
includesNonIdleWork,
173173
includesOnlyRetries,
174+
includesOnlyTransitions,
174175
getNextLanes,
175176
returnNextLanesPriority,
176177
setCurrentUpdateLanePriority,
@@ -302,7 +303,6 @@ const subtreeRenderLanesCursor: StackCursor<Lanes> = createCursor(NoLanes);
302303
let workInProgressRootExitStatus: RootExitStatus = RootIncomplete;
303304
// A fatal error, if one is thrown
304305
let workInProgressRootFatalError: mixed = null;
305-
let workInProgressRootLatestSuspenseTimeout: number = NoTimestamp;
306306
// "Included" lanes refer to lanes that were worked on during this render. It's
307307
// slightly different than `renderLanes` because `renderLanes` can change as you
308308
// enter and exit an Offscreen tree. This value is the combination of all render
@@ -322,7 +322,6 @@ let mostRecentlyUpdatedRoot: FiberRoot | null = null;
322322
// model where we don't commit new loading states in too quick succession.
323323
let globalMostRecentFallbackTime: number = 0;
324324
const FALLBACK_THROTTLE_MS: number = 500;
325-
const DEFAULT_TIMEOUT_MS: number = 5000;
326325

327326
// The absolute time for when we should start giving up on rendering
328327
// more and prefer CPU suspense heuristics instead.
@@ -922,12 +921,10 @@ function finishConcurrentRender(root, exitStatus, lanes) {
922921
case RootSuspendedWithDelay: {
923922
markRootSuspended(root, lanes);
924923

925-
if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) {
924+
if (includesOnlyTransitions(lanes)) {
926925
// This is a transition, so we should exit without committing a
927926
// placeholder and without scheduling a timeout. Delay indefinitely
928927
// until we receive more data.
929-
// TODO: Check the lanes to see if it's a transition, instead of
930-
// tracking the latest timeout.
931928
break;
932929
}
933930

@@ -1344,7 +1341,6 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes) {
13441341
workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
13451342
workInProgressRootExitStatus = RootIncomplete;
13461343
workInProgressRootFatalError = null;
1347-
workInProgressRootLatestSuspenseTimeout = NoTimestamp;
13481344
workInProgressRootSkippedLanes = NoLanes;
13491345
workInProgressRootUpdatedLanes = NoLanes;
13501346
workInProgressRootPingedLanes = NoLanes;
@@ -1456,29 +1452,6 @@ export function markCommitTimeOfFallback() {
14561452
globalMostRecentFallbackTime = now();
14571453
}
14581454

1459-
export function markRenderEventTimeAndConfig(
1460-
eventTime: number,
1461-
suspenseConfig: null | SuspenseConfig,
1462-
): void {
1463-
// Track the largest/latest timeout deadline in this batch.
1464-
// TODO: If there are two transitions in the same batch, shouldn't we
1465-
// choose the smaller one? Maybe this is because when an intermediate
1466-
// transition is superseded, we should ignore its suspense config, but
1467-
// we don't currently.
1468-
if (suspenseConfig !== null) {
1469-
// If `timeoutMs` is not specified, we default to 5 seconds. We have to
1470-
// resolve this default here because `suspenseConfig` is owned
1471-
// by userspace.
1472-
// TODO: Store this on the root instead (transition -> timeoutMs)
1473-
// TODO: Should this default to a JND instead?
1474-
const timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS;
1475-
const timeoutTime = eventTime + timeoutMs;
1476-
if (timeoutTime > workInProgressRootLatestSuspenseTimeout) {
1477-
workInProgressRootLatestSuspenseTimeout = timeoutTime;
1478-
}
1479-
}
1480-
}
1481-
14821455
export function markSkippedUpdateLanes(lane: Lane | Lanes): void {
14831456
workInProgressRootSkippedLanes = mergeLanes(
14841457
lane,

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ import {
157157
hasDiscreteLanes,
158158
includesNonIdleWork,
159159
includesOnlyRetries,
160+
includesOnlyTransitions,
160161
getNextLanes,
161162
returnNextLanesPriority,
162163
setCurrentUpdateLanePriority,
@@ -287,7 +288,6 @@ const subtreeRenderLanesCursor: StackCursor<Lanes> = createCursor(NoLanes);
287288
let workInProgressRootExitStatus: RootExitStatus = RootIncomplete;
288289
// A fatal error, if one is thrown
289290
let workInProgressRootFatalError: mixed = null;
290-
let workInProgressRootLatestSuspenseTimeout: number = NoTimestamp;
291291
// "Included" lanes refer to lanes that were worked on during this render. It's
292292
// slightly different than `renderLanes` because `renderLanes` can change as you
293293
// enter and exit an Offscreen tree. This value is the combination of all render
@@ -307,7 +307,6 @@ let mostRecentlyUpdatedRoot: FiberRoot | null = null;
307307
// model where we don't commit new loading states in too quick succession.
308308
let globalMostRecentFallbackTime: number = 0;
309309
const FALLBACK_THROTTLE_MS: number = 500;
310-
const DEFAULT_TIMEOUT_MS: number = 5000;
311310

312311
// The absolute time for when we should start giving up on rendering
313312
// more and prefer CPU suspense heuristics instead.
@@ -910,12 +909,10 @@ function finishConcurrentRender(root, exitStatus, lanes) {
910909
case RootSuspendedWithDelay: {
911910
markRootSuspended(root, lanes);
912911

913-
if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) {
912+
if (includesOnlyTransitions(lanes)) {
914913
// This is a transition, so we should exit without committing a
915914
// placeholder and without scheduling a timeout. Delay indefinitely
916915
// until we receive more data.
917-
// TODO: Check the lanes to see if it's a transition, instead of
918-
// tracking the latest timeout.
919916
break;
920917
}
921918

@@ -1332,7 +1329,6 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes) {
13321329
workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
13331330
workInProgressRootExitStatus = RootIncomplete;
13341331
workInProgressRootFatalError = null;
1335-
workInProgressRootLatestSuspenseTimeout = NoTimestamp;
13361332
workInProgressRootSkippedLanes = NoLanes;
13371333
workInProgressRootUpdatedLanes = NoLanes;
13381334
workInProgressRootPingedLanes = NoLanes;
@@ -1444,29 +1440,6 @@ export function markCommitTimeOfFallback() {
14441440
globalMostRecentFallbackTime = now();
14451441
}
14461442

1447-
export function markRenderEventTimeAndConfig(
1448-
eventTime: number,
1449-
suspenseConfig: null | SuspenseConfig,
1450-
): void {
1451-
// Track the largest/latest timeout deadline in this batch.
1452-
// TODO: If there are two transitions in the same batch, shouldn't we
1453-
// choose the smaller one? Maybe this is because when an intermediate
1454-
// transition is superseded, we should ignore its suspense config, but
1455-
// we don't currently.
1456-
if (suspenseConfig !== null) {
1457-
// If `timeoutMs` is not specified, we default to 5 seconds. We have to
1458-
// resolve this default here because `suspenseConfig` is owned
1459-
// by userspace.
1460-
// TODO: Store this on the root instead (transition -> timeoutMs)
1461-
// TODO: Should this default to a JND instead?
1462-
const timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS;
1463-
const timeoutTime = eventTime + timeoutMs;
1464-
if (timeoutTime > workInProgressRootLatestSuspenseTimeout) {
1465-
workInProgressRootLatestSuspenseTimeout = timeoutTime;
1466-
}
1467-
}
1468-
}
1469-
14701443
export function markSkippedUpdateLanes(lane: Lane | Lanes): void {
14711444
workInProgressRootSkippedLanes = mergeLanes(
14721445
lane,

packages/react-reconciler/src/ReactUpdateQueue.new.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ import {Callback, ShouldCapture, DidCapture} from './ReactSideEffectTags';
9898
import {debugRenderPhaseSideEffectsForStrictMode} from 'shared/ReactFeatureFlags';
9999

100100
import {StrictMode} from './ReactTypeOfMode';
101-
import {
102-
markRenderEventTimeAndConfig,
103-
markSkippedUpdateLanes,
104-
} from './ReactFiberWorkLoop.new';
101+
import {markSkippedUpdateLanes} from './ReactFiberWorkLoop.new';
105102

106103
import invariant from 'shared/invariant';
107104

@@ -519,14 +516,6 @@ export function processUpdateQueue<State>(
519516
newLastBaseUpdate = newLastBaseUpdate.next = clone;
520517
}
521518

522-
// Mark the event time of this update as relevant to this render pass.
523-
// TODO: This should ideally use the true event time of this update rather than
524-
// its priority which is a derived and not reversible value.
525-
// TODO: We should skip this update if it was already committed but currently
526-
// we have no way of detecting the difference between a committed and suspended
527-
// update here.
528-
markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig);
529-
530519
// Process this update.
531520
newState = getStateFromUpdate(
532521
workInProgress,

packages/react-reconciler/src/ReactUpdateQueue.old.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ import {Callback, ShouldCapture, DidCapture} from './ReactSideEffectTags';
9898
import {debugRenderPhaseSideEffectsForStrictMode} from 'shared/ReactFeatureFlags';
9999

100100
import {StrictMode} from './ReactTypeOfMode';
101-
import {
102-
markRenderEventTimeAndConfig,
103-
markSkippedUpdateLanes,
104-
} from './ReactFiberWorkLoop.old';
101+
import {markSkippedUpdateLanes} from './ReactFiberWorkLoop.old';
105102

106103
import invariant from 'shared/invariant';
107104

@@ -519,14 +516,6 @@ export function processUpdateQueue<State>(
519516
newLastBaseUpdate = newLastBaseUpdate.next = clone;
520517
}
521518

522-
// Mark the event time of this update as relevant to this render pass.
523-
// TODO: This should ideally use the true event time of this update rather than
524-
// its priority which is a derived and not reversible value.
525-
// TODO: We should skip this update if it was already committed but currently
526-
// we have no way of detecting the difference between a committed and suspended
527-
// update here.
528-
markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig);
529-
530519
// Process this update.
531520
newState = getStateFromUpdate(
532521
workInProgress,

0 commit comments

Comments
 (0)