From 92415819bd3cb47a7a47c9fe3f67b576c1c259c1 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Thu, 25 Mar 2021 00:07:03 -0500 Subject: [PATCH] Use highest priority lane to detect interruptions 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 01bcf19c91d84..08fb7b5b28c87 100644 --- a/packages/react-reconciler/src/ReactFiberLane.new.js +++ b/packages/react-reconciler/src/ReactFiberLane.new.js @@ -352,15 +352,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 90ffc05359683..77268ccc26969 100644 --- a/packages/react-reconciler/src/ReactFiberLane.old.js +++ b/packages/react-reconciler/src/ReactFiberLane.old.js @@ -352,15 +352,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;