Re-land "Delete LanePriority type (#21090)"
This re-lands commit 26ddc63f2dcc8e7dcbacf498237a2bb1e28a7d23.
Andrew Clark committed
May 3, 2021 at 13:34 UTC
df420bc0a360ae443ec447ca87808d91975e6b82
2 files changed
-152
packages/react-reconciler/src/ReactFiberLane.new.js
-76
@@ -11,25 +11,6 @@ import type {FiberRoot} from './ReactInternalTypes';
11
12
// TODO: Ideally these types would be opaque but that doesn't work well with
13
// 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;
14
15
export type Lanes = number;
16
export type Lane = number;
@@ -44,28 +25,6 @@ import {
25
import {isDevToolsPresent} from './ReactFiberDevToolsHook.new';
26
import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode';
27
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
-
28
// Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler.
29
// If those values are changed that package should be rebuilt and redeployed.
30
@@ -169,29 +128,19 @@ export const NoTimestamp = -1;
128
let nextTransitionLane: Lane = TransitionLane1;
129
let nextRetryLane: Lane = RetryLane1;
130
172
-// "Registers" used to "return" multiple values
173
-// Used by getHighestPriorityLanes and getNextLanes:
174
-let return_highestLanePriority: LanePriority = DefaultLanePriority;
175
-
131
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
132
switch (getHighestPriorityLane(lanes)) {
133
case SyncLane:
179
- return_highestLanePriority = SyncLanePriority;
134
return SyncLane;
135
case InputContinuousHydrationLane:
182
- return_highestLanePriority = InputContinuousHydrationLanePriority;
136
return InputContinuousHydrationLane;
137
case InputContinuousLane:
185
- return_highestLanePriority = InputContinuousLanePriority;
138
return InputContinuousLane;
139
case DefaultHydrationLane:
188
- return_highestLanePriority = DefaultHydrationLanePriority;
140
return DefaultHydrationLane;
141
case DefaultLane:
191
- return_highestLanePriority = DefaultLanePriority;
142
return DefaultLane;
143
case TransitionHydrationLane:
194
- return_highestLanePriority = TransitionHydrationPriority;
144
return TransitionHydrationLane;
145
case TransitionLane1:
146
case TransitionLane2:
@@ -209,26 +158,20 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
158
case TransitionLane14:
159
case TransitionLane15:
160
case TransitionLane16:
212
- return_highestLanePriority = TransitionPriority;
161
return lanes & TransitionLanes;
162
case RetryLane1:
163
case RetryLane2:
164
case RetryLane3:
165
case RetryLane4:
166
case RetryLane5:
219
- return_highestLanePriority = RetryLanePriority;
167
return lanes & RetryLanes;
168
case SelectiveHydrationLane:
222
- return_highestLanePriority = SelectiveHydrationLanePriority;
169
return SelectiveHydrationLane;
170
case IdleHydrationLane:
225
- return_highestLanePriority = IdleHydrationLanePriority;
171
return IdleHydrationLane;
172
case IdleLane:
228
- return_highestLanePriority = IdleLanePriority;
173
return IdleLane;
174
case OffscreenLane:
231
- return_highestLanePriority = OffscreenLanePriority;
175
return OffscreenLane;
176
default:
177
if (__DEV__) {
@@ -237,7 +180,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
180
);
181
}
182
// This shouldn't be reachable, but as a fallback, return the entire bitmask.
240
- return_highestLanePriority = DefaultLanePriority;
183
return lanes;
184
}
185
}
@@ -246,12 +188,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
188
// Early bailout if there's no pending work left.
189
const pendingLanes = root.pendingLanes;
190
if (pendingLanes === NoLanes) {
249
- return_highestLanePriority = NoLanePriority;
191
return NoLanes;
192
}
193
194
let nextLanes = NoLanes;
254
- let nextLanePriority = NoLanePriority;
195
196
const suspendedLanes = root.suspendedLanes;
197
const pingedLanes = root.pingedLanes;
@@ -263,12 +203,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
203
const nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
204
if (nonIdleUnblockedLanes !== NoLanes) {
205
nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
266
- nextLanePriority = return_highestLanePriority;
206
} else {
207
const nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
208
if (nonIdlePingedLanes !== NoLanes) {
209
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
271
- nextLanePriority = return_highestLanePriority;
210
}
211
}
212
} else {
@@ -276,11 +214,9 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
214
const unblockedLanes = pendingLanes & ~suspendedLanes;
215
if (unblockedLanes !== NoLanes) {
216
nextLanes = getHighestPriorityLanes(unblockedLanes);
279
- nextLanePriority = return_highestLanePriority;
217
} else {
218
if (pingedLanes !== NoLanes) {
219
nextLanes = getHighestPriorityLanes(pingedLanes);
283
- nextLanePriority = return_highestLanePriority;
220
}
221
}
222
}
@@ -314,8 +250,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
250
) {
251
// Keep working on the existing in-progress tree. Do not interrupt.
252
return wipLanes;
317
- } else {
318
- return_highestLanePriority = nextLanePriority;
253
}
254
}
255
@@ -511,9 +445,6 @@ export function getLanesToRetrySynchronouslyOnError(root: FiberRoot): Lanes {
445
return NoLanes;
446
}
447
514
-export function returnNextLanesPriority() {
515
- return return_highestLanePriority;
516
-}
448
export function includesNonIdleWork(lanes: Lanes) {
449
return (lanes & NonIdleLanes) !== NoLanes;
450
}
@@ -623,13 +554,6 @@ export function higherPriorityLane(a: Lane, b: Lane) {
554
return a !== NoLane && a < b ? a : b;
555
}
556
626
-export function higherLanePriority(
627
- a: LanePriority,
628
- b: LanePriority,
629
-): LanePriority {
630
- return a !== NoLanePriority && a > b ? a : b;
631
-}
632
-
557
export function createLaneMap<T>(initial: T): LaneMap<T> {
558
// Intentionally pushing one by one.
559
// https://v8.dev/blog/elements-kinds#avoid-creating-holes
packages/react-reconciler/src/ReactFiberLane.old.js
-76
@@ -11,25 +11,6 @@ import type {FiberRoot} from './ReactInternalTypes';
11
12
// TODO: Ideally these types would be opaque but that doesn't work well with
13
// 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;
14
15
export type Lanes = number;
16
export type Lane = number;
@@ -44,28 +25,6 @@ import {
25
import {isDevToolsPresent} from './ReactFiberDevToolsHook.old';
26
import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode';
27
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
-
28
// Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler.
29
// If those values are changed that package should be rebuilt and redeployed.
30
@@ -169,29 +128,19 @@ export const NoTimestamp = -1;
128
let nextTransitionLane: Lane = TransitionLane1;
129
let nextRetryLane: Lane = RetryLane1;
130
172
-// "Registers" used to "return" multiple values
173
-// Used by getHighestPriorityLanes and getNextLanes:
174
-let return_highestLanePriority: LanePriority = DefaultLanePriority;
175
-
131
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
132
switch (getHighestPriorityLane(lanes)) {
133
case SyncLane:
179
- return_highestLanePriority = SyncLanePriority;
134
return SyncLane;
135
case InputContinuousHydrationLane:
182
- return_highestLanePriority = InputContinuousHydrationLanePriority;
136
return InputContinuousHydrationLane;
137
case InputContinuousLane:
185
- return_highestLanePriority = InputContinuousLanePriority;
138
return InputContinuousLane;
139
case DefaultHydrationLane:
188
- return_highestLanePriority = DefaultHydrationLanePriority;
140
return DefaultHydrationLane;
141
case DefaultLane:
191
- return_highestLanePriority = DefaultLanePriority;
142
return DefaultLane;
143
case TransitionHydrationLane:
194
- return_highestLanePriority = TransitionHydrationPriority;
144
return TransitionHydrationLane;
145
case TransitionLane1:
146
case TransitionLane2:
@@ -209,26 +158,20 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
158
case TransitionLane14:
159
case TransitionLane15:
160
case TransitionLane16:
212
- return_highestLanePriority = TransitionPriority;
161
return lanes & TransitionLanes;
162
case RetryLane1:
163
case RetryLane2:
164
case RetryLane3:
165
case RetryLane4:
166
case RetryLane5:
219
- return_highestLanePriority = RetryLanePriority;
167
return lanes & RetryLanes;
168
case SelectiveHydrationLane:
222
- return_highestLanePriority = SelectiveHydrationLanePriority;
169
return SelectiveHydrationLane;
170
case IdleHydrationLane:
225
- return_highestLanePriority = IdleHydrationLanePriority;
171
return IdleHydrationLane;
172
case IdleLane:
228
- return_highestLanePriority = IdleLanePriority;
173
return IdleLane;
174
case OffscreenLane:
231
- return_highestLanePriority = OffscreenLanePriority;
175
return OffscreenLane;
176
default:
177
if (__DEV__) {
@@ -237,7 +180,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
180
);
181
}
182
// This shouldn't be reachable, but as a fallback, return the entire bitmask.
240
- return_highestLanePriority = DefaultLanePriority;
183
return lanes;
184
}
185
}
@@ -246,12 +188,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
188
// Early bailout if there's no pending work left.
189
const pendingLanes = root.pendingLanes;
190
if (pendingLanes === NoLanes) {
249
- return_highestLanePriority = NoLanePriority;
191
return NoLanes;
192
}
193
194
let nextLanes = NoLanes;
254
- let nextLanePriority = NoLanePriority;
195
196
const suspendedLanes = root.suspendedLanes;
197
const pingedLanes = root.pingedLanes;
@@ -263,12 +203,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
203
const nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
204
if (nonIdleUnblockedLanes !== NoLanes) {
205
nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
266
- nextLanePriority = return_highestLanePriority;
206
} else {
207
const nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
208
if (nonIdlePingedLanes !== NoLanes) {
209
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
271
- nextLanePriority = return_highestLanePriority;
210
}
211
}
212
} else {
@@ -276,11 +214,9 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
214
const unblockedLanes = pendingLanes & ~suspendedLanes;
215
if (unblockedLanes !== NoLanes) {
216
nextLanes = getHighestPriorityLanes(unblockedLanes);
279
- nextLanePriority = return_highestLanePriority;
217
} else {
218
if (pingedLanes !== NoLanes) {
219
nextLanes = getHighestPriorityLanes(pingedLanes);
283
- nextLanePriority = return_highestLanePriority;
220
}
221
}
222
}
@@ -314,8 +250,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
250
) {
251
// Keep working on the existing in-progress tree. Do not interrupt.
252
return wipLanes;
317
- } else {
318
- return_highestLanePriority = nextLanePriority;
253
}
254
}
255
@@ -511,9 +445,6 @@ export function getLanesToRetrySynchronouslyOnError(root: FiberRoot): Lanes {
445
return NoLanes;
446
}
447
514
-export function returnNextLanesPriority() {
515
- return return_highestLanePriority;
516
-}
448
export function includesNonIdleWork(lanes: Lanes) {
449
return (lanes & NonIdleLanes) !== NoLanes;
450
}
@@ -623,13 +554,6 @@ export function higherPriorityLane(a: Lane, b: Lane) {
554
return a !== NoLane && a < b ? a : b;
555
}
556
626
-export function higherLanePriority(
627
- a: LanePriority,
628
- b: LanePriority,
629
-): LanePriority {
630
- return a !== NoLanePriority && a > b ? a : b;
631
-}
632
-
557
export function createLaneMap<T>(initial: T): LaneMap<T> {
558
// Intentionally pushing one by one.
559
// https://v8.dev/blog/elements-kinds#avoid-creating-holes