Skip to content

Commit

Permalink
Small cleanup in ReactFiberCompleteWork (#27681)
Browse files Browse the repository at this point in the history
These are all functionally equivalent changes.

- remove double negation and more explicit naming of
`hadNoMutationsEffects`
- use docblock syntax that's consumed by Flow
- remove useless cast

DiffTrain build for commit c4c87e0.
  • Loading branch information
kassens committed Nov 10, 2023
1 parent ac243b7 commit c015bd8
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<cf7aa70650e042d314e5532e7bbcef6b>>
* @generated SignedSource<<13c422e8868327c7f616f089da284539>>
*/

"use strict";
Expand Down Expand Up @@ -16180,9 +16180,12 @@ if (__DEV__) {
};
}

/**
* Tag the fiber with an update effect. This turns a Placement into
* a PlacementAndUpdate.
*/

function markUpdate(workInProgress) {
// Tag the fiber with an update effect. This turns a Placement into
// a PlacementAndUpdate.
workInProgress.flags |= Update;
}

Expand Down Expand Up @@ -25355,7 +25358,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-canary-0e352ea01-20231109";
var ReactVersion = "18.3.0-canary-c4c87e049-20231110";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9044,7 +9044,7 @@ var devToolsConfig$jscomp$inline_1033 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-0e352ea01-20231109",
version: "18.3.0-canary-c4c87e049-20231110",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1226 = {
Expand Down Expand Up @@ -9075,7 +9075,7 @@ var internals$jscomp$inline_1226 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-0e352ea01-20231109"
reconcilerVersion: "18.3.0-canary-c4c87e049-20231110"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1227 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9470,7 +9470,7 @@ var devToolsConfig$jscomp$inline_1075 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-0e352ea01-20231109",
version: "18.3.0-canary-c4c87e049-20231110",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1267 = {
Expand Down Expand Up @@ -9501,7 +9501,7 @@ var internals$jscomp$inline_1267 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-0e352ea01-20231109"
reconcilerVersion: "18.3.0-canary-c4c87e049-20231110"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1268 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "18.3.0-canary-0e352ea01-20231109";
var ReactVersion = "18.3.0-canary-c4c87e049-20231110";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-0e352ea01-20231109";
exports.version = "18.3.0-canary-c4c87e049-20231110";
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-0e352ea01-20231109";
exports.version = "18.3.0-canary-c4c87e049-20231110";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0e352ea01c0209b6c5e23f0e857af4e01c783024
c4c87e049b891ebc38a7a14b8c93285c877e90af
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b0e1d88ed60247f6fdc4d9be0ba441b9>>
* @generated SignedSource<<82de3c20128bc9cf9a3e000de26414a9>>
*/

"use strict";
Expand Down Expand Up @@ -19178,27 +19178,33 @@ to return true:wantsResponderID| |
} // This function is called when a Suspense boundary suspends. It returns the
}

/**
* Tag the fiber with an update effect. This turns a Placement into
* a PlacementAndUpdate.
*/

function markUpdate(workInProgress) {
// Tag the fiber with an update effect. This turns a Placement into
// a PlacementAndUpdate.
workInProgress.flags |= Update;
}

function markRef(workInProgress) {
workInProgress.flags |= Ref | RefStatic;
}
/**
* In persistent mode, return whether this update needs to clone the subtree.
*/

function hadNoMutationsEffects(current, completedWork) {
function doesRequireClone(current, completedWork) {
var didBailout =
current !== null && current.child === completedWork.child;

if (didBailout) {
return true;
return false;
}

if ((completedWork.flags & ChildDeletion) !== NoFlags$1) {
return false;
} // TODO: If we move the `hadNoMutationsEffects` call after `bubbleProperties`
return true;
} // TODO: If we move the `doesRequireClone` call after `bubbleProperties`
// then we only have to check the `completedWork.subtreeFlags`.

var child = completedWork.child;
Expand All @@ -19208,13 +19214,13 @@ to return true:wantsResponderID| |
(child.flags & MutationMask) !== NoFlags$1 ||
(child.subtreeFlags & MutationMask) !== NoFlags$1
) {
return false;
return true;
}

child = child.sibling;
}

return true;
return false;
}

function appendAllChildren(
Expand Down Expand Up @@ -19272,8 +19278,6 @@ to return true:wantsResponderID| |
continue;
}

_node = _node;

if (_node === workInProgress) {
return;
} // $FlowFixMe[incompatible-use] found when upgrading Flow
Expand Down Expand Up @@ -19374,11 +19378,8 @@ to return true:wantsResponderID| |

function updateHostContainer(current, workInProgress) {
{
var portalOrRoot = workInProgress.stateNode;
var childrenUnchanged = hadNoMutationsEffects(current, workInProgress);

if (childrenUnchanged);
else {
if (doesRequireClone(current, workInProgress)) {
var portalOrRoot = workInProgress.stateNode;
var container = portalOrRoot.containerInfo;
var newChildSet = createContainerChildSet(); // If children might have changed, we have to add them all to the set.

Expand Down Expand Up @@ -19410,9 +19411,9 @@ to return true:wantsResponderID| |
var _oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
// This guarantees that we can reuse all of them.

var childrenUnchanged = hadNoMutationsEffects(current, workInProgress);
var requiresClone = doesRequireClone(current, workInProgress);

if (childrenUnchanged && _oldProps === newProps) {
if (!requiresClone && _oldProps === newProps) {
// No changes, just reuse the existing instance.
// Note that this might release a previous clone.
workInProgress.stateNode = currentInstance;
Expand All @@ -19422,7 +19423,7 @@ to return true:wantsResponderID| |
getHostContext();
var newChildSet = null;

if (!childrenUnchanged && passChildrenWhenCloningPersistedNodes) {
if (requiresClone && passChildrenWhenCloningPersistedNodes) {
newChildSet = createContainerChildSet(); // If children might have changed, we have to add them all to the set.

appendAllChildrenToContainer(
Expand All @@ -19440,7 +19441,7 @@ to return true:wantsResponderID| |
type,
_oldProps,
newProps,
childrenUnchanged,
!requiresClone,
newChildSet
);

Expand All @@ -19453,7 +19454,7 @@ to return true:wantsResponderID| |

workInProgress.stateNode = newInstance;

if (childrenUnchanged) {
if (!requiresClone) {
// If there are no other effects in this tree, we need to flag this node as having one.
// Even though we're not going to use it for anything.
// Otherwise parents won't know that there are new children to propagate upwards.
Expand Down Expand Up @@ -27804,7 +27805,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "18.3.0-canary-ee665331";
var ReactVersion = "18.3.0-canary-8403dc9a";

function createPortal$1(
children,
Expand Down
Loading

0 comments on commit c015bd8

Please sign in to comment.