Skip to content

Commit df420bc

Browse files
committed
Re-land "Delete LanePriority type (#21090)"
This re-lands commit 26ddc63.
1 parent ab5b379 commit df420bc

File tree

2 files changed

+0
-152
lines changed

2 files changed

+0
-152
lines changed

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

-76
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,6 @@ import type {FiberRoot} from './ReactInternalTypes';
1111

1212
// TODO: Ideally these types would be opaque but that doesn't work well with
1313
// our reconciler fork infra, since these leak into non-reconciler packages.
14-
export type LanePriority =
15-
| 0
16-
| 1
17-
| 2
18-
| 3
19-
| 4
20-
| 5
21-
| 6
22-
| 7
23-
| 8
24-
| 9
25-
| 10
26-
| 11
27-
| 12
28-
| 13
29-
| 14
30-
| 15
31-
| 16
32-
| 17;
3314

3415
export type Lanes = number;
3516
export type Lane = number;
@@ -44,28 +25,6 @@ import {
4425
import {isDevToolsPresent} from './ReactFiberDevToolsHook.new';
4526
import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode';
4627

47-
export const SyncLanePriority: LanePriority = 12;
48-
49-
const InputContinuousHydrationLanePriority: LanePriority = 11;
50-
export const InputContinuousLanePriority: LanePriority = 10;
51-
52-
const DefaultHydrationLanePriority: LanePriority = 9;
53-
export const DefaultLanePriority: LanePriority = 8;
54-
55-
const TransitionHydrationPriority: LanePriority = 7;
56-
export const TransitionPriority: LanePriority = 6;
57-
58-
const RetryLanePriority: LanePriority = 5;
59-
60-
const SelectiveHydrationLanePriority: LanePriority = 4;
61-
62-
const IdleHydrationLanePriority: LanePriority = 3;
63-
export const IdleLanePriority: LanePriority = 2;
64-
65-
const OffscreenLanePriority: LanePriority = 1;
66-
67-
export const NoLanePriority: LanePriority = 0;
68-
6928
// Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler.
7029
// If those values are changed that package should be rebuilt and redeployed.
7130

@@ -169,29 +128,19 @@ export const NoTimestamp = -1;
169128
let nextTransitionLane: Lane = TransitionLane1;
170129
let nextRetryLane: Lane = RetryLane1;
171130

172-
// "Registers" used to "return" multiple values
173-
// Used by getHighestPriorityLanes and getNextLanes:
174-
let return_highestLanePriority: LanePriority = DefaultLanePriority;
175-
176131
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
177132
switch (getHighestPriorityLane(lanes)) {
178133
case SyncLane:
179-
return_highestLanePriority = SyncLanePriority;
180134
return SyncLane;
181135
case InputContinuousHydrationLane:
182-
return_highestLanePriority = InputContinuousHydrationLanePriority;
183136
return InputContinuousHydrationLane;
184137
case InputContinuousLane:
185-
return_highestLanePriority = InputContinuousLanePriority;
186138
return InputContinuousLane;
187139
case DefaultHydrationLane:
188-
return_highestLanePriority = DefaultHydrationLanePriority;
189140
return DefaultHydrationLane;
190141
case DefaultLane:
191-
return_highestLanePriority = DefaultLanePriority;
192142
return DefaultLane;
193143
case TransitionHydrationLane:
194-
return_highestLanePriority = TransitionHydrationPriority;
195144
return TransitionHydrationLane;
196145
case TransitionLane1:
197146
case TransitionLane2:
@@ -209,26 +158,20 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
209158
case TransitionLane14:
210159
case TransitionLane15:
211160
case TransitionLane16:
212-
return_highestLanePriority = TransitionPriority;
213161
return lanes & TransitionLanes;
214162
case RetryLane1:
215163
case RetryLane2:
216164
case RetryLane3:
217165
case RetryLane4:
218166
case RetryLane5:
219-
return_highestLanePriority = RetryLanePriority;
220167
return lanes & RetryLanes;
221168
case SelectiveHydrationLane:
222-
return_highestLanePriority = SelectiveHydrationLanePriority;
223169
return SelectiveHydrationLane;
224170
case IdleHydrationLane:
225-
return_highestLanePriority = IdleHydrationLanePriority;
226171
return IdleHydrationLane;
227172
case IdleLane:
228-
return_highestLanePriority = IdleLanePriority;
229173
return IdleLane;
230174
case OffscreenLane:
231-
return_highestLanePriority = OffscreenLanePriority;
232175
return OffscreenLane;
233176
default:
234177
if (__DEV__) {
@@ -237,7 +180,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
237180
);
238181
}
239182
// This shouldn't be reachable, but as a fallback, return the entire bitmask.
240-
return_highestLanePriority = DefaultLanePriority;
241183
return lanes;
242184
}
243185
}
@@ -246,12 +188,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
246188
// Early bailout if there's no pending work left.
247189
const pendingLanes = root.pendingLanes;
248190
if (pendingLanes === NoLanes) {
249-
return_highestLanePriority = NoLanePriority;
250191
return NoLanes;
251192
}
252193

253194
let nextLanes = NoLanes;
254-
let nextLanePriority = NoLanePriority;
255195

256196
const suspendedLanes = root.suspendedLanes;
257197
const pingedLanes = root.pingedLanes;
@@ -263,24 +203,20 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
263203
const nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
264204
if (nonIdleUnblockedLanes !== NoLanes) {
265205
nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
266-
nextLanePriority = return_highestLanePriority;
267206
} else {
268207
const nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
269208
if (nonIdlePingedLanes !== NoLanes) {
270209
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
271-
nextLanePriority = return_highestLanePriority;
272210
}
273211
}
274212
} else {
275213
// The only remaining work is Idle.
276214
const unblockedLanes = pendingLanes & ~suspendedLanes;
277215
if (unblockedLanes !== NoLanes) {
278216
nextLanes = getHighestPriorityLanes(unblockedLanes);
279-
nextLanePriority = return_highestLanePriority;
280217
} else {
281218
if (pingedLanes !== NoLanes) {
282219
nextLanes = getHighestPriorityLanes(pingedLanes);
283-
nextLanePriority = return_highestLanePriority;
284220
}
285221
}
286222
}
@@ -314,8 +250,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
314250
) {
315251
// Keep working on the existing in-progress tree. Do not interrupt.
316252
return wipLanes;
317-
} else {
318-
return_highestLanePriority = nextLanePriority;
319253
}
320254
}
321255

@@ -511,9 +445,6 @@ export function getLanesToRetrySynchronouslyOnError(root: FiberRoot): Lanes {
511445
return NoLanes;
512446
}
513447

514-
export function returnNextLanesPriority() {
515-
return return_highestLanePriority;
516-
}
517448
export function includesNonIdleWork(lanes: Lanes) {
518449
return (lanes & NonIdleLanes) !== NoLanes;
519450
}
@@ -623,13 +554,6 @@ export function higherPriorityLane(a: Lane, b: Lane) {
623554
return a !== NoLane && a < b ? a : b;
624555
}
625556

626-
export function higherLanePriority(
627-
a: LanePriority,
628-
b: LanePriority,
629-
): LanePriority {
630-
return a !== NoLanePriority && a > b ? a : b;
631-
}
632-
633557
export function createLaneMap<T>(initial: T): LaneMap<T> {
634558
// Intentionally pushing one by one.
635559
// https://v8.dev/blog/elements-kinds#avoid-creating-holes

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

-76
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,6 @@ import type {FiberRoot} from './ReactInternalTypes';
1111

1212
// TODO: Ideally these types would be opaque but that doesn't work well with
1313
// our reconciler fork infra, since these leak into non-reconciler packages.
14-
export type LanePriority =
15-
| 0
16-
| 1
17-
| 2
18-
| 3
19-
| 4
20-
| 5
21-
| 6
22-
| 7
23-
| 8
24-
| 9
25-
| 10
26-
| 11
27-
| 12
28-
| 13
29-
| 14
30-
| 15
31-
| 16
32-
| 17;
3314

3415
export type Lanes = number;
3516
export type Lane = number;
@@ -44,28 +25,6 @@ import {
4425
import {isDevToolsPresent} from './ReactFiberDevToolsHook.old';
4526
import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode';
4627

47-
export const SyncLanePriority: LanePriority = 12;
48-
49-
const InputContinuousHydrationLanePriority: LanePriority = 11;
50-
export const InputContinuousLanePriority: LanePriority = 10;
51-
52-
const DefaultHydrationLanePriority: LanePriority = 9;
53-
export const DefaultLanePriority: LanePriority = 8;
54-
55-
const TransitionHydrationPriority: LanePriority = 7;
56-
export const TransitionPriority: LanePriority = 6;
57-
58-
const RetryLanePriority: LanePriority = 5;
59-
60-
const SelectiveHydrationLanePriority: LanePriority = 4;
61-
62-
const IdleHydrationLanePriority: LanePriority = 3;
63-
export const IdleLanePriority: LanePriority = 2;
64-
65-
const OffscreenLanePriority: LanePriority = 1;
66-
67-
export const NoLanePriority: LanePriority = 0;
68-
6928
// Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler.
7029
// If those values are changed that package should be rebuilt and redeployed.
7130

@@ -169,29 +128,19 @@ export const NoTimestamp = -1;
169128
let nextTransitionLane: Lane = TransitionLane1;
170129
let nextRetryLane: Lane = RetryLane1;
171130

172-
// "Registers" used to "return" multiple values
173-
// Used by getHighestPriorityLanes and getNextLanes:
174-
let return_highestLanePriority: LanePriority = DefaultLanePriority;
175-
176131
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
177132
switch (getHighestPriorityLane(lanes)) {
178133
case SyncLane:
179-
return_highestLanePriority = SyncLanePriority;
180134
return SyncLane;
181135
case InputContinuousHydrationLane:
182-
return_highestLanePriority = InputContinuousHydrationLanePriority;
183136
return InputContinuousHydrationLane;
184137
case InputContinuousLane:
185-
return_highestLanePriority = InputContinuousLanePriority;
186138
return InputContinuousLane;
187139
case DefaultHydrationLane:
188-
return_highestLanePriority = DefaultHydrationLanePriority;
189140
return DefaultHydrationLane;
190141
case DefaultLane:
191-
return_highestLanePriority = DefaultLanePriority;
192142
return DefaultLane;
193143
case TransitionHydrationLane:
194-
return_highestLanePriority = TransitionHydrationPriority;
195144
return TransitionHydrationLane;
196145
case TransitionLane1:
197146
case TransitionLane2:
@@ -209,26 +158,20 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
209158
case TransitionLane14:
210159
case TransitionLane15:
211160
case TransitionLane16:
212-
return_highestLanePriority = TransitionPriority;
213161
return lanes & TransitionLanes;
214162
case RetryLane1:
215163
case RetryLane2:
216164
case RetryLane3:
217165
case RetryLane4:
218166
case RetryLane5:
219-
return_highestLanePriority = RetryLanePriority;
220167
return lanes & RetryLanes;
221168
case SelectiveHydrationLane:
222-
return_highestLanePriority = SelectiveHydrationLanePriority;
223169
return SelectiveHydrationLane;
224170
case IdleHydrationLane:
225-
return_highestLanePriority = IdleHydrationLanePriority;
226171
return IdleHydrationLane;
227172
case IdleLane:
228-
return_highestLanePriority = IdleLanePriority;
229173
return IdleLane;
230174
case OffscreenLane:
231-
return_highestLanePriority = OffscreenLanePriority;
232175
return OffscreenLane;
233176
default:
234177
if (__DEV__) {
@@ -237,7 +180,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
237180
);
238181
}
239182
// This shouldn't be reachable, but as a fallback, return the entire bitmask.
240-
return_highestLanePriority = DefaultLanePriority;
241183
return lanes;
242184
}
243185
}
@@ -246,12 +188,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
246188
// Early bailout if there's no pending work left.
247189
const pendingLanes = root.pendingLanes;
248190
if (pendingLanes === NoLanes) {
249-
return_highestLanePriority = NoLanePriority;
250191
return NoLanes;
251192
}
252193

253194
let nextLanes = NoLanes;
254-
let nextLanePriority = NoLanePriority;
255195

256196
const suspendedLanes = root.suspendedLanes;
257197
const pingedLanes = root.pingedLanes;
@@ -263,24 +203,20 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
263203
const nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
264204
if (nonIdleUnblockedLanes !== NoLanes) {
265205
nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
266-
nextLanePriority = return_highestLanePriority;
267206
} else {
268207
const nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
269208
if (nonIdlePingedLanes !== NoLanes) {
270209
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
271-
nextLanePriority = return_highestLanePriority;
272210
}
273211
}
274212
} else {
275213
// The only remaining work is Idle.
276214
const unblockedLanes = pendingLanes & ~suspendedLanes;
277215
if (unblockedLanes !== NoLanes) {
278216
nextLanes = getHighestPriorityLanes(unblockedLanes);
279-
nextLanePriority = return_highestLanePriority;
280217
} else {
281218
if (pingedLanes !== NoLanes) {
282219
nextLanes = getHighestPriorityLanes(pingedLanes);
283-
nextLanePriority = return_highestLanePriority;
284220
}
285221
}
286222
}
@@ -314,8 +250,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
314250
) {
315251
// Keep working on the existing in-progress tree. Do not interrupt.
316252
return wipLanes;
317-
} else {
318-
return_highestLanePriority = nextLanePriority;
319253
}
320254
}
321255

@@ -511,9 +445,6 @@ export function getLanesToRetrySynchronouslyOnError(root: FiberRoot): Lanes {
511445
return NoLanes;
512446
}
513447

514-
export function returnNextLanesPriority() {
515-
return return_highestLanePriority;
516-
}
517448
export function includesNonIdleWork(lanes: Lanes) {
518449
return (lanes & NonIdleLanes) !== NoLanes;
519450
}
@@ -623,13 +554,6 @@ export function higherPriorityLane(a: Lane, b: Lane) {
623554
return a !== NoLane && a < b ? a : b;
624555
}
625556

626-
export function higherLanePriority(
627-
a: LanePriority,
628-
b: LanePriority,
629-
): LanePriority {
630-
return a !== NoLanePriority && a > b ? a : b;
631-
}
632-
633557
export function createLaneMap<T>(initial: T): LaneMap<T> {
634558
// Intentionally pushing one by one.
635559
// https://v8.dev/blog/elements-kinds#avoid-creating-holes

0 commit comments

Comments
 (0)