Skip to content

Commit 58742c2

Browse files
authored
Delete unused eventTimes Fiber field (#26599)
1 parent 0b931f9 commit 58742c2

11 files changed

+37
-133
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ import {
142142
OffscreenLane,
143143
DefaultHydrationLane,
144144
SomeRetryLane,
145-
NoTimestamp,
146145
includesSomeLane,
147146
laneToLanes,
148147
removeLanes,
@@ -2876,15 +2875,8 @@ function updateDehydratedSuspenseComponent(
28762875
// is one of the very rare times where we mutate the current tree
28772876
// during the render phase.
28782877
suspenseState.retryLane = attemptHydrationAtLane;
2879-
// TODO: Ideally this would inherit the event time of the current render
2880-
const eventTime = NoTimestamp;
28812878
enqueueConcurrentRenderForLane(current, attemptHydrationAtLane);
2882-
scheduleUpdateOnFiber(
2883-
root,
2884-
current,
2885-
attemptHydrationAtLane,
2886-
eventTime,
2887-
);
2879+
scheduleUpdateOnFiber(root, current, attemptHydrationAtLane);
28882880

28892881
// Throw a special object that signals to the work loop that it should
28902882
// interrupt the current render.

packages/react-reconciler/src/ReactFiberClassComponent.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ import {
6464
emptyContextObject,
6565
} from './ReactFiberContext';
6666
import {readContext, checkIfContextChanged} from './ReactFiberNewContext';
67-
import {
68-
requestEventTime,
69-
requestUpdateLane,
70-
scheduleUpdateOnFiber,
71-
} from './ReactFiberWorkLoop';
67+
import {requestUpdateLane, scheduleUpdateOnFiber} from './ReactFiberWorkLoop';
7268
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
7369
import {
7470
markForceUpdateScheduled,
@@ -213,8 +209,7 @@ const classComponentUpdater = {
213209

214210
const root = enqueueUpdate(fiber, update, lane);
215211
if (root !== null) {
216-
const eventTime = requestEventTime();
217-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
212+
scheduleUpdateOnFiber(root, fiber, lane);
218213
entangleTransitions(root, fiber, lane);
219214
}
220215

@@ -248,8 +243,7 @@ const classComponentUpdater = {
248243

249244
const root = enqueueUpdate(fiber, update, lane);
250245
if (root !== null) {
251-
const eventTime = requestEventTime();
252-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
246+
scheduleUpdateOnFiber(root, fiber, lane);
253247
entangleTransitions(root, fiber, lane);
254248
}
255249

@@ -283,8 +277,7 @@ const classComponentUpdater = {
283277

284278
const root = enqueueUpdate(fiber, update, lane);
285279
if (root !== null) {
286-
const eventTime = requestEventTime();
287-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
280+
scheduleUpdateOnFiber(root, fiber, lane);
288281
entangleTransitions(root, fiber, lane);
289282
}
290283

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
} from './ReactFiberConfig';
1919
import type {Fiber, FiberRoot} from './ReactInternalTypes';
2020
import type {Lanes} from './ReactFiberLane';
21-
import {NoTimestamp, SyncLane} from './ReactFiberLane';
21+
import {SyncLane} from './ReactFiberLane';
2222
import type {SuspenseState, RetryQueue} from './ReactFiberSuspenseComponent';
2323
import type {UpdateQueue} from './ReactFiberClassUpdateQueue';
2424
import type {FunctionComponentUpdateQueue} from './ReactFiberHooks';
@@ -2415,7 +2415,7 @@ export function detachOffscreenInstance(instance: OffscreenInstance): void {
24152415
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
24162416
if (root !== null) {
24172417
instance._pendingVisibility |= OffscreenDetached;
2418-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
2418+
scheduleUpdateOnFiber(root, fiber, SyncLane);
24192419
}
24202420
}
24212421

@@ -2435,7 +2435,7 @@ export function attachOffscreenInstance(instance: OffscreenInstance): void {
24352435
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
24362436
if (root !== null) {
24372437
instance._pendingVisibility &= ~OffscreenDetached;
2438-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
2438+
scheduleUpdateOnFiber(root, fiber, SyncLane);
24392439
}
24402440
}
24412441

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import {
7070
isTransitionLane,
7171
markRootEntangled,
7272
markRootMutableRead,
73-
NoTimestamp,
7473
} from './ReactFiberLane';
7574
import {
7675
ContinuousEventPriority,
@@ -101,7 +100,6 @@ import {
101100
getWorkInProgressRootRenderLanes,
102101
scheduleUpdateOnFiber,
103102
requestUpdateLane,
104-
requestEventTime,
105103
markSkippedUpdateLanes,
106104
isInvalidExecutionContextForEventFunction,
107105
} from './ReactFiberWorkLoop';
@@ -1837,7 +1835,7 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
18371835
function forceStoreRerender(fiber: Fiber) {
18381836
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
18391837
if (root !== null) {
1840-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
1838+
scheduleUpdateOnFiber(root, fiber, SyncLane);
18411839
}
18421840
}
18431841

@@ -2558,8 +2556,7 @@ function refreshCache<T>(fiber: Fiber, seedKey: ?() => T, seedValue: T): void {
25582556
const refreshUpdate = createLegacyQueueUpdate(lane);
25592557
const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane);
25602558
if (root !== null) {
2561-
const eventTime = requestEventTime();
2562-
scheduleUpdateOnFiber(root, provider, lane, eventTime);
2559+
scheduleUpdateOnFiber(root, provider, lane);
25632560
entangleLegacyQueueTransitions(root, provider, lane);
25642561
}
25652562

@@ -2623,8 +2620,7 @@ function dispatchReducerAction<S, A>(
26232620
} else {
26242621
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
26252622
if (root !== null) {
2626-
const eventTime = requestEventTime();
2627-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
2623+
scheduleUpdateOnFiber(root, fiber, lane);
26282624
entangleTransitionUpdate(root, queue, lane);
26292625
}
26302626
}
@@ -2706,8 +2702,7 @@ function dispatchSetState<S, A>(
27062702

27072703
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
27082704
if (root !== null) {
2709-
const eventTime = requestEventTime();
2710-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
2705+
scheduleUpdateOnFiber(root, fiber, lane);
27112706
entangleTransitionUpdate(root, queue, lane);
27122707
}
27132708
}

packages/react-reconciler/src/ReactFiberHotReloading.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates';
2424
import {updateContainer} from './ReactFiberReconciler';
2525
import {emptyContextObject} from './ReactFiberContext';
26-
import {SyncLane, NoTimestamp} from './ReactFiberLane';
26+
import {SyncLane} from './ReactFiberLane';
2727
import {
2828
ClassComponent,
2929
FunctionComponent,
@@ -328,7 +328,7 @@ function scheduleFibersWithFamiliesRecursively(
328328
if (needsRemount || needsRender) {
329329
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
330330
if (root !== null) {
331-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
331+
scheduleUpdateOnFiber(root, fiber, SyncLane);
332332
}
333333
}
334334
if (child !== null && !needsRemount) {

packages/react-reconciler/src/ReactFiberLane.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -319,25 +319,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
319319
return nextLanes;
320320
}
321321

322-
export function getMostRecentEventTime(root: FiberRoot, lanes: Lanes): number {
323-
const eventTimes = root.eventTimes;
324-
325-
let mostRecentEventTime = NoTimestamp;
326-
while (lanes > 0) {
327-
const index = pickArbitraryLaneIndex(lanes);
328-
const lane = 1 << index;
329-
330-
const eventTime = eventTimes[index];
331-
if (eventTime > mostRecentEventTime) {
332-
mostRecentEventTime = eventTime;
333-
}
334-
335-
lanes &= ~lane;
336-
}
337-
338-
return mostRecentEventTime;
339-
}
340-
341322
function computeExpirationTime(lane: Lane, currentTime: number) {
342323
switch (lane) {
343324
case SyncHydrationLane:
@@ -599,11 +580,7 @@ export function createLaneMap<T>(initial: T): LaneMap<T> {
599580
return laneMap;
600581
}
601582

602-
export function markRootUpdated(
603-
root: FiberRoot,
604-
updateLane: Lane,
605-
eventTime: number,
606-
) {
583+
export function markRootUpdated(root: FiberRoot, updateLane: Lane) {
607584
root.pendingLanes |= updateLane;
608585

609586
// If there are any suspended transitions, it's possible this new update
@@ -622,12 +599,6 @@ export function markRootUpdated(
622599
root.suspendedLanes = NoLanes;
623600
root.pingedLanes = NoLanes;
624601
}
625-
626-
const eventTimes = root.eventTimes;
627-
const index = laneToIndex(updateLane);
628-
// We can always overwrite an existing timestamp because we prefer the most
629-
// recent event, and we assume time is monotonically increasing.
630-
eventTimes[index] = eventTime;
631602
}
632603

633604
export function markRootSuspended(root: FiberRoot, suspendedLanes: Lanes) {
@@ -672,7 +643,6 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) {
672643
root.errorRecoveryDisabledLanes &= remainingLanes;
673644

674645
const entanglements = root.entanglements;
675-
const eventTimes = root.eventTimes;
676646
const expirationTimes = root.expirationTimes;
677647
const hiddenUpdates = root.hiddenUpdates;
678648

@@ -683,7 +653,6 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) {
683653
const lane = 1 << index;
684654

685655
entanglements[index] = NoLanes;
686-
eventTimes[index] = NoTimestamp;
687656
expirationTimes[index] = NoTimestamp;
688657

689658
const hiddenUpdatesForLane = hiddenUpdates[index];

packages/react-reconciler/src/ReactFiberReconciler.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import {
5656
onScheduleRoot,
5757
} from './ReactFiberDevToolsHook';
5858
import {
59-
requestEventTime,
6059
requestUpdateLane,
6160
scheduleUpdateOnFiber,
6261
scheduleInitialHydrationOnRoot,
@@ -84,7 +83,6 @@ import {StrictLegacyMode} from './ReactTypeOfMode';
8483
import {
8584
SyncLane,
8685
SelectiveHydrationLane,
87-
NoTimestamp,
8886
getHighestPriorityPendingLanes,
8987
higherPriorityLane,
9088
} from './ReactFiberLane';
@@ -311,9 +309,8 @@ export function createHydrationContainer(
311309
const update = createUpdate(lane);
312310
update.callback =
313311
callback !== undefined && callback !== null ? callback : null;
314-
const eventTime = requestEventTime();
315312
enqueueUpdate(current, update, lane);
316-
scheduleInitialHydrationOnRoot(root, lane, eventTime);
313+
scheduleInitialHydrationOnRoot(root, lane);
317314

318315
return root;
319316
}
@@ -379,8 +376,7 @@ export function updateContainer(
379376

380377
const root = enqueueUpdate(current, update, lane);
381378
if (root !== null) {
382-
const eventTime = requestEventTime();
383-
scheduleUpdateOnFiber(root, current, lane, eventTime);
379+
scheduleUpdateOnFiber(root, current, lane);
384380
entangleTransitions(root, current, lane);
385381
}
386382

@@ -427,8 +423,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
427423
flushSync(() => {
428424
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
429425
if (root !== null) {
430-
const eventTime = requestEventTime();
431-
scheduleUpdateOnFiber(root, fiber, SyncLane, eventTime);
426+
scheduleUpdateOnFiber(root, fiber, SyncLane);
432427
}
433428
});
434429
// If we're still blocked after this, we need to increase
@@ -471,8 +466,7 @@ export function attemptContinuousHydration(fiber: Fiber): void {
471466
const lane = SelectiveHydrationLane;
472467
const root = enqueueConcurrentRenderForLane(fiber, lane);
473468
if (root !== null) {
474-
const eventTime = requestEventTime();
475-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
469+
scheduleUpdateOnFiber(root, fiber, lane);
476470
}
477471
markRetryLaneIfNotHydrated(fiber, lane);
478472
}
@@ -486,8 +480,7 @@ export function attemptHydrationAtCurrentPriority(fiber: Fiber): void {
486480
const lane = requestUpdateLane(fiber);
487481
const root = enqueueConcurrentRenderForLane(fiber, lane);
488482
if (root !== null) {
489-
const eventTime = requestEventTime();
490-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
483+
scheduleUpdateOnFiber(root, fiber, lane);
491484
}
492485
markRetryLaneIfNotHydrated(fiber, lane);
493486
}
@@ -666,7 +659,7 @@ if (__DEV__) {
666659

667660
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
668661
if (root !== null) {
669-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
662+
scheduleUpdateOnFiber(root, fiber, SyncLane);
670663
}
671664
}
672665
};
@@ -690,7 +683,7 @@ if (__DEV__) {
690683

691684
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
692685
if (root !== null) {
693-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
686+
scheduleUpdateOnFiber(root, fiber, SyncLane);
694687
}
695688
}
696689
};
@@ -715,7 +708,7 @@ if (__DEV__) {
715708

716709
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
717710
if (root !== null) {
718-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
711+
scheduleUpdateOnFiber(root, fiber, SyncLane);
719712
}
720713
}
721714
};
@@ -728,7 +721,7 @@ if (__DEV__) {
728721
}
729722
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
730723
if (root !== null) {
731-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
724+
scheduleUpdateOnFiber(root, fiber, SyncLane);
732725
}
733726
};
734727
overridePropsDeletePath = (fiber: Fiber, path: Array<string | number>) => {
@@ -738,7 +731,7 @@ if (__DEV__) {
738731
}
739732
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
740733
if (root !== null) {
741-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
734+
scheduleUpdateOnFiber(root, fiber, SyncLane);
742735
}
743736
};
744737
overridePropsRenamePath = (
@@ -752,14 +745,14 @@ if (__DEV__) {
752745
}
753746
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
754747
if (root !== null) {
755-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
748+
scheduleUpdateOnFiber(root, fiber, SyncLane);
756749
}
757750
};
758751

759752
scheduleUpdate = (fiber: Fiber) => {
760753
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
761754
if (root !== null) {
762-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
755+
scheduleUpdateOnFiber(root, fiber, SyncLane);
763756
}
764757
};
765758

packages/react-reconciler/src/ReactFiberRoot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ function FiberRootNode(
6666
this.next = null;
6767
this.callbackNode = null;
6868
this.callbackPriority = NoLane;
69-
this.eventTimes = createLaneMap(NoLanes);
7069
this.expirationTimes = createLaneMap(NoTimestamp);
7170

7271
this.pendingLanes = NoLanes;

0 commit comments

Comments
 (0)