@@ -11,25 +11,6 @@ import type {FiberRoot} from './ReactInternalTypes'; |
11 | 11 |
|
12 | 12 | // TODO: Ideally these types would be opaque but that doesn't work well with |
13 | 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; |
33 | 14 |
|
34 | 15 | export type Lanes = number; |
35 | 16 | export type Lane = number; |
@@ -44,28 +25,6 @@ import { |
44 | 25 | import {isDevToolsPresent} from './ReactFiberDevToolsHook.new'; |
45 | 26 | import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode'; |
46 | 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 | | - |
69 | 28 | // Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler. |
70 | 29 | // If those values are changed that package should be rebuilt and redeployed. |
71 | 30 |
|
@@ -169,29 +128,19 @@ export const NoTimestamp = -1; |
169 | 128 | let nextTransitionLane: Lane = TransitionLane1; |
170 | 129 | let nextRetryLane: Lane = RetryLane1; |
171 | 130 |
|
172 | | -// "Registers" used to "return" multiple values |
173 | | -// Used by getHighestPriorityLanes and getNextLanes: |
174 | | -let return_highestLanePriority: LanePriority = DefaultLanePriority; |
175 | | - |
176 | 131 | function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes { |
177 | 132 | switch (getHighestPriorityLane(lanes)) { |
178 | 133 | case SyncLane: |
179 | | - return_highestLanePriority = SyncLanePriority; |
180 | 134 | return SyncLane; |
181 | 135 | case InputContinuousHydrationLane: |
182 | | - return_highestLanePriority = InputContinuousHydrationLanePriority; |
183 | 136 | return InputContinuousHydrationLane; |
184 | 137 | case InputContinuousLane: |
185 | | - return_highestLanePriority = InputContinuousLanePriority; |
186 | 138 | return InputContinuousLane; |
187 | 139 | case DefaultHydrationLane: |
188 | | - return_highestLanePriority = DefaultHydrationLanePriority; |
189 | 140 | return DefaultHydrationLane; |
190 | 141 | case DefaultLane: |
191 | | - return_highestLanePriority = DefaultLanePriority; |
192 | 142 | return DefaultLane; |
193 | 143 | case TransitionHydrationLane: |
194 | | - return_highestLanePriority = TransitionHydrationPriority; |
195 | 144 | return TransitionHydrationLane; |
196 | 145 | case TransitionLane1: |
197 | 146 | case TransitionLane2: |
@@ -209,26 +158,20 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes { |
209 | 158 | case TransitionLane14: |
210 | 159 | case TransitionLane15: |
211 | 160 | case TransitionLane16: |
212 | | - return_highestLanePriority = TransitionPriority; |
213 | 161 | return lanes & TransitionLanes; |
214 | 162 | case RetryLane1: |
215 | 163 | case RetryLane2: |
216 | 164 | case RetryLane3: |
217 | 165 | case RetryLane4: |
218 | 166 | case RetryLane5: |
219 | | - return_highestLanePriority = RetryLanePriority; |
220 | 167 | return lanes & RetryLanes; |
221 | 168 | case SelectiveHydrationLane: |
222 | | - return_highestLanePriority = SelectiveHydrationLanePriority; |
223 | 169 | return SelectiveHydrationLane; |
224 | 170 | case IdleHydrationLane: |
225 | | - return_highestLanePriority = IdleHydrationLanePriority; |
226 | 171 | return IdleHydrationLane; |
227 | 172 | case IdleLane: |
228 | | - return_highestLanePriority = IdleLanePriority; |
229 | 173 | return IdleLane; |
230 | 174 | case OffscreenLane: |
231 | | - return_highestLanePriority = OffscreenLanePriority; |
232 | 175 | return OffscreenLane; |
233 | 176 | default: |
234 | 177 | if (__DEV__) { |
@@ -237,7 +180,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes { |
237 | 180 | ); |
238 | 181 | } |
239 | 182 | // This shouldn't be reachable, but as a fallback, return the entire bitmask. |
240 | | - return_highestLanePriority = DefaultLanePriority; |
241 | 183 | return lanes; |
242 | 184 | } |
243 | 185 | } |
@@ -246,12 +188,10 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { |
246 | 188 | // Early bailout if there's no pending work left. |
247 | 189 | const pendingLanes = root.pendingLanes; |
248 | 190 | if (pendingLanes === NoLanes) { |
249 | | - return_highestLanePriority = NoLanePriority; |
250 | 191 | return NoLanes; |
251 | 192 | } |
252 | 193 |
|
253 | 194 | let nextLanes = NoLanes; |
254 | | - let nextLanePriority = NoLanePriority; |
255 | 195 |
|
256 | 196 | const suspendedLanes = root.suspendedLanes; |
257 | 197 | const pingedLanes = root.pingedLanes; |
@@ -263,24 +203,20 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { |
263 | 203 | const nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; |
264 | 204 | if (nonIdleUnblockedLanes !== NoLanes) { |
265 | 205 | nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); |
266 | | - nextLanePriority = return_highestLanePriority; |
267 | 206 | } else { |
268 | 207 | const nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; |
269 | 208 | if (nonIdlePingedLanes !== NoLanes) { |
270 | 209 | nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); |
271 | | - nextLanePriority = return_highestLanePriority; |
272 | 210 | } |
273 | 211 | } |
274 | 212 | } else { |
275 | 213 | // The only remaining work is Idle. |
276 | 214 | const unblockedLanes = pendingLanes & ~suspendedLanes; |
277 | 215 | if (unblockedLanes !== NoLanes) { |
278 | 216 | nextLanes = getHighestPriorityLanes(unblockedLanes); |
279 | | - nextLanePriority = return_highestLanePriority; |
280 | 217 | } else { |
281 | 218 | if (pingedLanes !== NoLanes) { |
282 | 219 | nextLanes = getHighestPriorityLanes(pingedLanes); |
283 | | - nextLanePriority = return_highestLanePriority; |
284 | 220 | } |
285 | 221 | } |
286 | 222 | } |
@@ -314,8 +250,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { |
314 | 250 | ) { |
315 | 251 | // Keep working on the existing in-progress tree. Do not interrupt. |
316 | 252 | return wipLanes; |
317 | | - } else { |
318 | | - return_highestLanePriority = nextLanePriority; |
319 | 253 | } |
320 | 254 | } |
321 | 255 |
|
@@ -511,9 +445,6 @@ export function getLanesToRetrySynchronouslyOnError(root: FiberRoot): Lanes { |
511 | 445 | return NoLanes; |
512 | 446 | } |
513 | 447 |
|
514 | | -export function returnNextLanesPriority() { |
515 | | - return return_highestLanePriority; |
516 | | -} |
517 | 448 | export function includesNonIdleWork(lanes: Lanes) { |
518 | 449 | return (lanes & NonIdleLanes) !== NoLanes; |
519 | 450 | } |
@@ -623,13 +554,6 @@ export function higherPriorityLane(a: Lane, b: Lane) { |
623 | 554 | return a !== NoLane && a < b ? a : b; |
624 | 555 | } |
625 | 556 |
|
626 | | -export function higherLanePriority( |
627 | | - a: LanePriority, |
628 | | - b: LanePriority, |
629 | | -): LanePriority { |
630 | | - return a !== NoLanePriority && a > b ? a : b; |
631 | | -} |
632 | | - |
633 | 557 | export function createLaneMap<T>(initial: T): LaneMap<T> { |
634 | 558 | // Intentionally pushing one by one. |
635 | 559 | // https://v8.dev/blog/elements-kinds#avoid-creating-holes |
|