Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c67be212d | ||
|
|
93e0bdf2ee | ||
|
|
a684f09e58 |
@@ -243,11 +243,7 @@ function updatePureComponent(
|
||||
) {
|
||||
const render = Component.render;
|
||||
|
||||
if (
|
||||
current !== null &&
|
||||
(updateExpirationTime === NoWork ||
|
||||
updateExpirationTime > renderExpirationTime)
|
||||
) {
|
||||
if (current !== null && updateExpirationTime > renderExpirationTime) {
|
||||
const prevProps = current.memoizedProps;
|
||||
// Default to shallow comparison
|
||||
let compare = Component.compare;
|
||||
@@ -1351,10 +1347,7 @@ function bailoutOnAlreadyFinishedWork(
|
||||
|
||||
// Check if the children have any pending work.
|
||||
const childExpirationTime = workInProgress.childExpirationTime;
|
||||
if (
|
||||
childExpirationTime === NoWork ||
|
||||
childExpirationTime > renderExpirationTime
|
||||
) {
|
||||
if (childExpirationTime > renderExpirationTime) {
|
||||
// The children don't have any work either. We can skip them.
|
||||
// TODO: Once we add back resuming, we should check if the children are
|
||||
// a work-in-progress set. If so, we need to transfer their effects.
|
||||
@@ -1380,8 +1373,7 @@ function beginWork(
|
||||
if (
|
||||
oldProps === newProps &&
|
||||
!hasLegacyContextChanged() &&
|
||||
(updateExpirationTime === NoWork ||
|
||||
updateExpirationTime > renderExpirationTime)
|
||||
updateExpirationTime > renderExpirationTime
|
||||
) {
|
||||
// This fiber does not have any pending work. Bailout without entering
|
||||
// the begin phase. There's still some bookkeeping we that needs to be done
|
||||
|
||||
@@ -11,9 +11,9 @@ import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt';
|
||||
|
||||
export type ExpirationTime = number;
|
||||
|
||||
export const NoWork = 0;
|
||||
export const NoWork = MAX_SIGNED_31_BIT_INT;
|
||||
export const Sync = 1;
|
||||
export const Never = MAX_SIGNED_31_BIT_INT;
|
||||
export const Never = MAX_SIGNED_31_BIT_INT - 1;
|
||||
|
||||
const UNIT_SIZE = 10;
|
||||
const MAGIC_NUMBER_OFFSET = 2;
|
||||
|
||||
@@ -22,7 +22,6 @@ import warningWithoutStack from 'shared/warningWithoutStack';
|
||||
import {isPrimaryRenderer} from './ReactFiberHostConfig';
|
||||
import {createCursor, push, pop} from './ReactFiberStack';
|
||||
import maxSigned31BitInt from './maxSigned31BitInt';
|
||||
import {NoWork} from './ReactFiberExpirationTime';
|
||||
import {
|
||||
ContextProvider,
|
||||
ClassComponent,
|
||||
@@ -177,17 +176,13 @@ export function propagateContextChange(
|
||||
enqueueUpdate(fiber, update);
|
||||
}
|
||||
|
||||
if (
|
||||
fiber.expirationTime === NoWork ||
|
||||
fiber.expirationTime > renderExpirationTime
|
||||
) {
|
||||
if (fiber.expirationTime > renderExpirationTime) {
|
||||
fiber.expirationTime = renderExpirationTime;
|
||||
}
|
||||
let alternate = fiber.alternate;
|
||||
if (
|
||||
alternate !== null &&
|
||||
(alternate.expirationTime === NoWork ||
|
||||
alternate.expirationTime > renderExpirationTime)
|
||||
alternate.expirationTime > renderExpirationTime
|
||||
) {
|
||||
alternate.expirationTime = renderExpirationTime;
|
||||
}
|
||||
@@ -196,22 +191,17 @@ export function propagateContextChange(
|
||||
let node = fiber.return;
|
||||
while (node !== null) {
|
||||
alternate = node.alternate;
|
||||
if (
|
||||
node.childExpirationTime === NoWork ||
|
||||
node.childExpirationTime > renderExpirationTime
|
||||
) {
|
||||
if (node.childExpirationTime > renderExpirationTime) {
|
||||
node.childExpirationTime = renderExpirationTime;
|
||||
if (
|
||||
alternate !== null &&
|
||||
(alternate.childExpirationTime === NoWork ||
|
||||
alternate.childExpirationTime > renderExpirationTime)
|
||||
alternate.childExpirationTime > renderExpirationTime
|
||||
) {
|
||||
alternate.childExpirationTime = renderExpirationTime;
|
||||
}
|
||||
} else if (
|
||||
alternate !== null &&
|
||||
(alternate.childExpirationTime === NoWork ||
|
||||
alternate.childExpirationTime > renderExpirationTime)
|
||||
alternate.childExpirationTime > renderExpirationTime
|
||||
) {
|
||||
alternate.childExpirationTime = renderExpirationTime;
|
||||
} else {
|
||||
|
||||
@@ -225,18 +225,10 @@ export function findEarliestOutstandingPriorityLevel(
|
||||
|
||||
const earliestPendingTime = root.earliestPendingTime;
|
||||
const earliestSuspendedTime = root.earliestSuspendedTime;
|
||||
if (
|
||||
earliestExpirationTime === NoWork ||
|
||||
(earliestPendingTime !== NoWork &&
|
||||
earliestPendingTime < earliestExpirationTime)
|
||||
) {
|
||||
if (earliestPendingTime < earliestExpirationTime) {
|
||||
earliestExpirationTime = earliestPendingTime;
|
||||
}
|
||||
if (
|
||||
earliestExpirationTime === NoWork ||
|
||||
(earliestSuspendedTime !== NoWork &&
|
||||
earliestSuspendedTime < earliestExpirationTime)
|
||||
) {
|
||||
if (earliestSuspendedTime < earliestExpirationTime) {
|
||||
earliestExpirationTime = earliestSuspendedTime;
|
||||
}
|
||||
return earliestExpirationTime;
|
||||
@@ -278,11 +270,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) {
|
||||
}
|
||||
|
||||
let expirationTime = nextExpirationTimeToWorkOn;
|
||||
if (
|
||||
expirationTime !== NoWork &&
|
||||
earliestSuspendedTime !== NoWork &&
|
||||
earliestSuspendedTime < expirationTime
|
||||
) {
|
||||
if (expirationTime !== NoWork && earliestSuspendedTime < expirationTime) {
|
||||
// Expire using the earliest known expiration time.
|
||||
expirationTime = earliestSuspendedTime;
|
||||
}
|
||||
|
||||
@@ -556,9 +556,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
|
||||
const updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
|
||||
const childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
|
||||
const earliestRemainingTimeBeforeCommit =
|
||||
updateExpirationTimeBeforeCommit === NoWork ||
|
||||
(childExpirationTimeBeforeCommit !== NoWork &&
|
||||
childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit)
|
||||
childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit
|
||||
? childExpirationTimeBeforeCommit
|
||||
: updateExpirationTimeBeforeCommit;
|
||||
markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
|
||||
@@ -733,9 +731,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
|
||||
const updateExpirationTimeAfterCommit = finishedWork.expirationTime;
|
||||
const childExpirationTimeAfterCommit = finishedWork.childExpirationTime;
|
||||
const earliestRemainingTimeAfterCommit =
|
||||
updateExpirationTimeAfterCommit === NoWork ||
|
||||
(childExpirationTimeAfterCommit !== NoWork &&
|
||||
childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit)
|
||||
childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit
|
||||
? childExpirationTimeAfterCommit
|
||||
: updateExpirationTimeAfterCommit;
|
||||
if (earliestRemainingTimeAfterCommit === NoWork) {
|
||||
@@ -776,10 +772,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
|
||||
// Only decrement the pending interaction count if we're done.
|
||||
// If there's still work at the current priority,
|
||||
// That indicates that we are waiting for suspense data.
|
||||
if (
|
||||
earliestRemainingTimeAfterCommit === NoWork ||
|
||||
scheduledExpirationTime < earliestRemainingTimeAfterCommit
|
||||
) {
|
||||
if (scheduledExpirationTime < earliestRemainingTimeAfterCommit) {
|
||||
pendingInteractionMap.delete(scheduledExpirationTime);
|
||||
|
||||
scheduledInteractions.forEach(interaction => {
|
||||
@@ -839,18 +832,10 @@ function resetChildExpirationTime(
|
||||
while (child !== null) {
|
||||
const childUpdateExpirationTime = child.expirationTime;
|
||||
const childChildExpirationTime = child.childExpirationTime;
|
||||
if (
|
||||
newChildExpirationTime === NoWork ||
|
||||
(childUpdateExpirationTime !== NoWork &&
|
||||
childUpdateExpirationTime < newChildExpirationTime)
|
||||
) {
|
||||
if (childUpdateExpirationTime < newChildExpirationTime) {
|
||||
newChildExpirationTime = childUpdateExpirationTime;
|
||||
}
|
||||
if (
|
||||
newChildExpirationTime === NoWork ||
|
||||
(childChildExpirationTime !== NoWork &&
|
||||
childChildExpirationTime < newChildExpirationTime)
|
||||
) {
|
||||
if (childChildExpirationTime < newChildExpirationTime) {
|
||||
newChildExpirationTime = childChildExpirationTime;
|
||||
}
|
||||
if (shouldBubbleActualDurations) {
|
||||
@@ -866,18 +851,10 @@ function resetChildExpirationTime(
|
||||
while (child !== null) {
|
||||
const childUpdateExpirationTime = child.expirationTime;
|
||||
const childChildExpirationTime = child.childExpirationTime;
|
||||
if (
|
||||
newChildExpirationTime === NoWork ||
|
||||
(childUpdateExpirationTime !== NoWork &&
|
||||
childUpdateExpirationTime < newChildExpirationTime)
|
||||
) {
|
||||
if (childUpdateExpirationTime < newChildExpirationTime) {
|
||||
newChildExpirationTime = childUpdateExpirationTime;
|
||||
}
|
||||
if (
|
||||
newChildExpirationTime === NoWork ||
|
||||
(childChildExpirationTime !== NoWork &&
|
||||
childChildExpirationTime < newChildExpirationTime)
|
||||
) {
|
||||
if (childChildExpirationTime < newChildExpirationTime) {
|
||||
newChildExpirationTime = childChildExpirationTime;
|
||||
}
|
||||
child = child.sibling;
|
||||
@@ -1545,7 +1522,10 @@ function computeExpirationForFiber(currentTime: ExpirationTime, fiber: Fiber) {
|
||||
// This is an interactive update. Keep track of the lowest pending
|
||||
// interactive expiration time. This allows us to synchronously flush
|
||||
// all interactive updates when needed.
|
||||
if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) {
|
||||
if (
|
||||
lowestPriorityPendingInteractiveExpirationTime === NoWork ||
|
||||
expirationTime > lowestPriorityPendingInteractiveExpirationTime
|
||||
) {
|
||||
lowestPriorityPendingInteractiveExpirationTime = expirationTime;
|
||||
}
|
||||
}
|
||||
@@ -1642,18 +1622,11 @@ function scheduleWorkToRoot(fiber: Fiber, expirationTime): FiberRoot | null {
|
||||
}
|
||||
|
||||
// Update the source fiber's expiration time
|
||||
if (
|
||||
fiber.expirationTime === NoWork ||
|
||||
fiber.expirationTime > expirationTime
|
||||
) {
|
||||
if (fiber.expirationTime > expirationTime) {
|
||||
fiber.expirationTime = expirationTime;
|
||||
}
|
||||
let alternate = fiber.alternate;
|
||||
if (
|
||||
alternate !== null &&
|
||||
(alternate.expirationTime === NoWork ||
|
||||
alternate.expirationTime > expirationTime)
|
||||
) {
|
||||
if (alternate !== null && alternate.expirationTime > expirationTime) {
|
||||
alternate.expirationTime = expirationTime;
|
||||
}
|
||||
// Walk the parent path to the root and update the child expiration time.
|
||||
@@ -1664,22 +1637,17 @@ function scheduleWorkToRoot(fiber: Fiber, expirationTime): FiberRoot | null {
|
||||
} else {
|
||||
while (node !== null) {
|
||||
alternate = node.alternate;
|
||||
if (
|
||||
node.childExpirationTime === NoWork ||
|
||||
node.childExpirationTime > expirationTime
|
||||
) {
|
||||
if (node.childExpirationTime > expirationTime) {
|
||||
node.childExpirationTime = expirationTime;
|
||||
if (
|
||||
alternate !== null &&
|
||||
(alternate.childExpirationTime === NoWork ||
|
||||
alternate.childExpirationTime > expirationTime)
|
||||
alternate.childExpirationTime > expirationTime
|
||||
) {
|
||||
alternate.childExpirationTime = expirationTime;
|
||||
}
|
||||
} else if (
|
||||
alternate !== null &&
|
||||
(alternate.childExpirationTime === NoWork ||
|
||||
alternate.childExpirationTime > expirationTime)
|
||||
alternate.childExpirationTime > expirationTime
|
||||
) {
|
||||
alternate.childExpirationTime = expirationTime;
|
||||
}
|
||||
@@ -2028,10 +1996,7 @@ function addRootToSchedule(root: FiberRoot, expirationTime: ExpirationTime) {
|
||||
} else {
|
||||
// This root is already scheduled, but its priority may have increased.
|
||||
const remainingExpirationTime = root.expirationTime;
|
||||
if (
|
||||
remainingExpirationTime === NoWork ||
|
||||
expirationTime < remainingExpirationTime
|
||||
) {
|
||||
if (expirationTime < remainingExpirationTime) {
|
||||
// Update the priority.
|
||||
root.expirationTime = expirationTime;
|
||||
}
|
||||
@@ -2080,10 +2045,7 @@ function findHighestPriorityRoot() {
|
||||
}
|
||||
root = previousScheduledRoot.nextScheduledRoot;
|
||||
} else {
|
||||
if (
|
||||
highestPriorityWork === NoWork ||
|
||||
remainingExpirationTime < highestPriorityWork
|
||||
) {
|
||||
if (remainingExpirationTime < highestPriorityWork) {
|
||||
// Update the priority, if it's higher
|
||||
highestPriorityWork = remainingExpirationTime;
|
||||
highestPriorityRoot = root;
|
||||
@@ -2150,8 +2112,7 @@ function performWork(minExpirationTime: ExpirationTime, dl: Deadline | null) {
|
||||
while (
|
||||
nextFlushedRoot !== null &&
|
||||
nextFlushedExpirationTime !== NoWork &&
|
||||
(minExpirationTime === NoWork ||
|
||||
minExpirationTime >= nextFlushedExpirationTime) &&
|
||||
minExpirationTime >= nextFlushedExpirationTime &&
|
||||
(!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime)
|
||||
) {
|
||||
performWorkOnRoot(
|
||||
@@ -2167,8 +2128,7 @@ function performWork(minExpirationTime: ExpirationTime, dl: Deadline | null) {
|
||||
while (
|
||||
nextFlushedRoot !== null &&
|
||||
nextFlushedExpirationTime !== NoWork &&
|
||||
(minExpirationTime === NoWork ||
|
||||
minExpirationTime >= nextFlushedExpirationTime)
|
||||
minExpirationTime >= nextFlushedExpirationTime
|
||||
) {
|
||||
performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true);
|
||||
findHighestPriorityRoot();
|
||||
|
||||
@@ -437,10 +437,7 @@ export function processUpdateQueue<State>(
|
||||
}
|
||||
// Since this update will remain in the list, update the remaining
|
||||
// expiration time.
|
||||
if (
|
||||
newExpirationTime === NoWork ||
|
||||
newExpirationTime > updateExpirationTime
|
||||
) {
|
||||
if (newExpirationTime > updateExpirationTime) {
|
||||
newExpirationTime = updateExpirationTime;
|
||||
}
|
||||
} else {
|
||||
@@ -490,10 +487,7 @@ export function processUpdateQueue<State>(
|
||||
}
|
||||
// Since this update will remain in the list, update the remaining
|
||||
// expiration time.
|
||||
if (
|
||||
newExpirationTime === NoWork ||
|
||||
newExpirationTime > updateExpirationTime
|
||||
) {
|
||||
if (newExpirationTime > updateExpirationTime) {
|
||||
newExpirationTime = updateExpirationTime;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -249,7 +249,7 @@ exports[`ReactDebugFiberPerf measures deprioritized work 1`] = `
|
||||
⚛ (Committing Host Effects: 1 Total)
|
||||
⚛ (Calling Lifecycle Methods: 0 Total)
|
||||
|
||||
⚛ (Waiting for async callback... will force flush in 10737418210 ms)
|
||||
⚛ (Waiting for async callback... will force flush in 10737418200 ms)
|
||||
|
||||
// Flush the child
|
||||
⚛ (React Tree Reconciliation: Completed Root)
|
||||
|
||||
Reference in New Issue
Block a user