From 4a99c5c3a780d8178d9278c29d0b7f44be6a0dce Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Thu, 25 Mar 2021 11:36:17 -0500 Subject: [PATCH] Use highest priority lane to detect interruptions (#21088) Instead of LanePriority. I'm removing all uses of LanePriority so I can delete it. --- packages/react-reconciler/src/ReactFiberLane.new.js | 11 ++++++----- packages/react-reconciler/src/ReactFiberLane.old.js | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberLane.new.js b/packages/react-reconciler/src/ReactFiberLane.new.js index 9791ac07d4690..227526858b22a 100644 --- a/packages/react-reconciler/src/ReactFiberLane.new.js +++ b/packages/react-reconciler/src/ReactFiberLane.new.js @@ -334,15 +334,16 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { // bother waiting until the root is complete. (wipLanes & suspendedLanes) === NoLanes ) { - getHighestPriorityLanes(wipLanes); - const wipLanePriority = return_highestLanePriority; + const nextLane = getHighestPriorityLane(nextLanes); + const wipLane = getHighestPriorityLane(wipLanes); if ( - nextLanePriority <= wipLanePriority || + // Tests whether the next lane is equal or lower priority than the wip + // one. This works because the bits decrease in priority as you go left. + nextLane >= wipLane || // Default priority updates should not interrupt transition updates. The // only difference between default updates and transition updates is that // default updates do not support refresh transitions. - (nextLanePriority === DefaultLanePriority && - wipLanePriority === TransitionPriority) + (nextLane === DefaultLane && (wipLane & TransitionLanes) !== NoLanes) ) { // Keep working on the existing in-progress tree. Do not interrupt. return wipLanes; diff --git a/packages/react-reconciler/src/ReactFiberLane.old.js b/packages/react-reconciler/src/ReactFiberLane.old.js index 9e578d27163ee..2380acd634f15 100644 --- a/packages/react-reconciler/src/ReactFiberLane.old.js +++ b/packages/react-reconciler/src/ReactFiberLane.old.js @@ -334,15 +334,16 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { // bother waiting until the root is complete. (wipLanes & suspendedLanes) === NoLanes ) { - getHighestPriorityLanes(wipLanes); - const wipLanePriority = return_highestLanePriority; + const nextLane = getHighestPriorityLane(nextLanes); + const wipLane = getHighestPriorityLane(wipLanes); if ( - nextLanePriority <= wipLanePriority || + // Tests whether the next lane is equal or lower priority than the wip + // one. This works because the bits decrease in priority as you go left. + nextLane >= wipLane || // Default priority updates should not interrupt transition updates. The // only difference between default updates and transition updates is that // default updates do not support refresh transitions. - (nextLanePriority === DefaultLanePriority && - wipLanePriority === TransitionPriority) + (nextLane === DefaultLane && (wipLane & TransitionLanes) !== NoLanes) ) { // Keep working on the existing in-progress tree. Do not interrupt. return wipLanes;