Skip to content

Commit

Permalink
Remove unused arguments in the reconciler (#18092)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 21, 2020
1 parent 5de5b61 commit 8b596e0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 69 deletions.
43 changes: 13 additions & 30 deletions packages/react-reconciler/src/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return existingChildren;
}

function useFiber(
fiber: Fiber,
pendingProps: mixed,
expirationTime: ExpirationTime,
): Fiber {
function useFiber(fiber: Fiber, pendingProps: mixed): Fiber {
// We currently set sibling to null and index to 0 here because it is easy
// to forget to do before returning it. E.g. for the single child case.
const clone = createWorkInProgress(fiber, pendingProps, expirationTime);
const clone = createWorkInProgress(fiber, pendingProps);
clone.index = 0;
clone.sibling = null;
return clone;
Expand Down Expand Up @@ -392,7 +388,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return created;
} else {
// Update
const existing = useFiber(current, textContent, expirationTime);
const existing = useFiber(current, textContent);
existing.return = returnFiber;
return existing;
}
Expand All @@ -411,7 +407,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(__DEV__ ? isCompatibleFamilyForHotReloading(current, element) : false)
) {
// Move based on index
const existing = useFiber(current, element.props, expirationTime);
const existing = useFiber(current, element.props);
existing.ref = coerceRef(returnFiber, current, element);
existing.return = returnFiber;
if (__DEV__) {
Expand All @@ -426,7 +422,7 @@ function ChildReconciler(shouldTrackSideEffects) {
element.type.render === current.type.render
) {
// Same as above but also update the .type field.
const existing = useFiber(current, element.props, expirationTime);
const existing = useFiber(current, element.props);
existing.return = returnFiber;
existing.type = element.type;
if (__DEV__) {
Expand Down Expand Up @@ -469,7 +465,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return created;
} else {
// Update
const existing = useFiber(current, portal.children || [], expirationTime);
const existing = useFiber(current, portal.children || []);
existing.return = returnFiber;
return existing;
}
Expand All @@ -494,7 +490,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return created;
} else {
// Update
const existing = useFiber(current, fragment, expirationTime);
const existing = useFiber(current, fragment);
existing.return = returnFiber;
return existing;
}
Expand Down Expand Up @@ -1137,7 +1133,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// We already have an existing node so let's just update it and delete
// the rest.
deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
const existing = useFiber(currentFirstChild, textContent, expirationTime);
const existing = useFiber(currentFirstChild, textContent);
existing.return = returnFiber;
return existing;
}
Expand Down Expand Up @@ -1169,11 +1165,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case Fragment: {
if (element.type === REACT_FRAGMENT_TYPE) {
deleteRemainingChildren(returnFiber, child.sibling);
const existing = useFiber(
child,
element.props.children,
expirationTime,
);
const existing = useFiber(child, element.props.children);
existing.return = returnFiber;
if (__DEV__) {
existing._debugSource = element._source;
Expand All @@ -1190,7 +1182,7 @@ function ChildReconciler(shouldTrackSideEffects) {
element.type.render === child.type.render
) {
deleteRemainingChildren(returnFiber, child.sibling);
const existing = useFiber(child, element.props, expirationTime);
const existing = useFiber(child, element.props);
existing.type = element.type;
existing.return = returnFiber;
if (__DEV__) {
Expand All @@ -1211,7 +1203,7 @@ function ChildReconciler(shouldTrackSideEffects) {
: false)
) {
deleteRemainingChildren(returnFiber, child.sibling);
const existing = useFiber(child, element.props, expirationTime);
const existing = useFiber(child, element.props);
existing.ref = coerceRef(returnFiber, child, element);
existing.return = returnFiber;
if (__DEV__) {
Expand Down Expand Up @@ -1271,11 +1263,7 @@ function ChildReconciler(shouldTrackSideEffects) {
child.stateNode.implementation === portal.implementation
) {
deleteRemainingChildren(returnFiber, child.sibling);
const existing = useFiber(
child,
portal.children || [],
expirationTime,
);
const existing = useFiber(child, portal.children || []);
existing.return = returnFiber;
return existing;
} else {
Expand Down Expand Up @@ -1441,11 +1429,7 @@ export function cloneChildFibers(
}

let currentChild = workInProgress.child;
let newChild = createWorkInProgress(
currentChild,
currentChild.pendingProps,
currentChild.expirationTime,
);
let newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
workInProgress.child = newChild;

newChild.return = workInProgress;
Expand All @@ -1454,7 +1438,6 @@ export function cloneChildFibers(
newChild = newChild.sibling = createWorkInProgress(
currentChild,
currentChild.pendingProps,
currentChild.expirationTime,
);
newChild.return = workInProgress;
}
Expand Down
6 changes: 1 addition & 5 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,7 @@ export function resolveLazyComponentTag(Component: Function): WorkTag {
}

// This is used to create an alternate fiber to do work on.
export function createWorkInProgress(
current: Fiber,
pendingProps: any,
expirationTime: ExpirationTime,
): Fiber {
export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
let workInProgress = current.alternate;
if (workInProgress === null) {
// We use a double buffering pooling technique because we know that we'll
Expand Down
22 changes: 3 additions & 19 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,7 @@ function updateMemoComponent(
}
// React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
let newChild = createWorkInProgress(
currentChild,
nextProps,
renderExpirationTime,
);
let newChild = createWorkInProgress(currentChild, nextProps);
newChild.ref = workInProgress.ref;
newChild.return = workInProgress;
workInProgress.child = newChild;
Expand Down Expand Up @@ -831,12 +827,7 @@ function updateClassComponent(
workInProgress.effectTag |= Placement;
}
// In the initial pass we might need to construct the instance.
constructClassInstance(
workInProgress,
Component,
nextProps,
renderExpirationTime,
);
constructClassInstance(workInProgress, Component, nextProps);
mountClassInstance(
workInProgress,
Component,
Expand Down Expand Up @@ -1296,12 +1287,7 @@ function mountIncompleteClassComponent(
}
prepareToReadContext(workInProgress, renderExpirationTime);

constructClassInstance(
workInProgress,
Component,
nextProps,
renderExpirationTime,
);
constructClassInstance(workInProgress, Component, nextProps);
mountClassInstance(
workInProgress,
Component,
Expand Down Expand Up @@ -1871,7 +1857,6 @@ function updateSuspenseComponent(
const primaryChildFragment = createWorkInProgress(
currentPrimaryChildFragment,
currentPrimaryChildFragment.pendingProps,
NoWork,
);
primaryChildFragment.return = workInProgress;

Expand Down Expand Up @@ -1911,7 +1896,6 @@ function updateSuspenseComponent(
const fallbackChildFragment = createWorkInProgress(
currentFallbackChildFragment,
nextFallbackChildren,
currentFallbackChildFragment.expirationTime,
);
fallbackChildFragment.return = workInProgress;
primaryChildFragment.sibling = fallbackChildFragment;
Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ function constructClassInstance(
workInProgress: Fiber,
ctor: any,
props: any,
renderExpirationTime: ExpirationTime,
): any {
let isLegacyContextConsumer = false;
let unmaskedContext = emptyContextObject;
Expand Down
14 changes: 2 additions & 12 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,7 @@ function commitLifeCycles(
// We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
commitUpdateQueue(
finishedWork,
updateQueue,
instance,
committedExpirationTime,
);
commitUpdateQueue(finishedWork, updateQueue, instance);
}
return;
}
Expand All @@ -599,12 +594,7 @@ function commitLifeCycles(
break;
}
}
commitUpdateQueue(
finishedWork,
updateQueue,
instance,
committedExpirationTime,
);
commitUpdateQueue(finishedWork, updateQueue, instance);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ function prepareFreshStack(root, expirationTime) {
}
}
workInProgressRoot = root;
workInProgress = createWorkInProgress(root.current, null, expirationTime);
workInProgress = createWorkInProgress(root.current, null);
renderExpirationTime = expirationTime;
workInProgressRootExitStatus = RootIncomplete;
workInProgressRootFatalError = null;
Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactUpdateQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ export function commitUpdateQueue<State>(
finishedWork: Fiber,
finishedQueue: UpdateQueue<State>,
instance: any,
renderExpirationTime: ExpirationTime,
): void {
// Commit the effects
const effects = finishedQueue.effects;
Expand Down

0 comments on commit 8b596e0

Please sign in to comment.