Fabric: Fixed order of instructions in Differentiator
Summary: @public Previously Differentiator might generate some `remove` instruction that refers to already `deleted` node. That diffs fixes that. Reviewed By: fkgozali Differential Revision: D8596536 fbshipit-source-id: 88117962f93e52167dbcb6525f2cc36758a367e7
This commit is contained in:
parent
b1c4fee6af
commit
250cc3c594
|
@ -39,6 +39,7 @@ static void calculateMutationInstructions(
|
||||||
TreeMutationInstructionList removeInstructions = {};
|
TreeMutationInstructionList removeInstructions = {};
|
||||||
TreeMutationInstructionList replaceInstructions = {};
|
TreeMutationInstructionList replaceInstructions = {};
|
||||||
TreeMutationInstructionList downwardInstructions = {};
|
TreeMutationInstructionList downwardInstructions = {};
|
||||||
|
TreeMutationInstructionList destructionDownwardInstructions = {};
|
||||||
|
|
||||||
// Stage 1: Collectings Updates
|
// Stage 1: Collectings Updates
|
||||||
for (index = 0; index < oldChildNodes->size() && index < newChildNodes->size(); index++) {
|
for (index = 0; index < oldChildNodes->size() && index < newChildNodes->size(); index++) {
|
||||||
|
@ -62,7 +63,7 @@ static void calculateMutationInstructions(
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateMutationInstructions(
|
calculateMutationInstructions(
|
||||||
downwardInstructions,
|
*(newChildNode->getChildren()->size() ? &downwardInstructions : &destructionDownwardInstructions),
|
||||||
oldChildNode,
|
oldChildNode,
|
||||||
oldChildNode->getChildren(),
|
oldChildNode->getChildren(),
|
||||||
newChildNode->getChildren()
|
newChildNode->getChildren()
|
||||||
|
@ -90,7 +91,7 @@ static void calculateMutationInstructions(
|
||||||
newChildSourceNode ? newChildSourceNode->getChildren() : ShadowNode::emptySharedShadowNodeSharedList();
|
newChildSourceNode ? newChildSourceNode->getChildren() : ShadowNode::emptySharedShadowNodeSharedList();
|
||||||
|
|
||||||
calculateMutationInstructions(
|
calculateMutationInstructions(
|
||||||
downwardInstructions,
|
*(newChildNode->getChildren()->size() ? &downwardInstructions : &destructionDownwardInstructions),
|
||||||
newChildNode,
|
newChildNode,
|
||||||
newChildSourceChildNodes,
|
newChildSourceChildNodes,
|
||||||
newChildNode->getChildren()
|
newChildNode->getChildren()
|
||||||
|
@ -125,7 +126,7 @@ static void calculateMutationInstructions(
|
||||||
);
|
);
|
||||||
|
|
||||||
calculateMutationInstructions(
|
calculateMutationInstructions(
|
||||||
downwardInstructions,
|
destructionDownwardInstructions,
|
||||||
oldChildNode,
|
oldChildNode,
|
||||||
oldChildNode->getChildren(),
|
oldChildNode->getChildren(),
|
||||||
ShadowNode::emptySharedShadowNodeSharedList()
|
ShadowNode::emptySharedShadowNodeSharedList()
|
||||||
|
@ -149,15 +150,15 @@ static void calculateMutationInstructions(
|
||||||
}
|
}
|
||||||
|
|
||||||
// All instructions in an optimal order:
|
// All instructions in an optimal order:
|
||||||
|
instructions.insert(instructions.end(), destructionDownwardInstructions.begin(), destructionDownwardInstructions.end());
|
||||||
instructions.insert(instructions.end(), replaceInstructions.begin(), replaceInstructions.end());
|
instructions.insert(instructions.end(), replaceInstructions.begin(), replaceInstructions.end());
|
||||||
instructions.insert(instructions.end(), removeInstructions.begin(), removeInstructions.end());
|
instructions.insert(instructions.end(), removeInstructions.begin(), removeInstructions.end());
|
||||||
instructions.insert(instructions.end(), deleteInstructions.begin(), deleteInstructions.end());
|
|
||||||
instructions.insert(instructions.end(), createInstructions.begin(), createInstructions.end());
|
instructions.insert(instructions.end(), createInstructions.begin(), createInstructions.end());
|
||||||
instructions.insert(instructions.end(), insertInstructions.begin(), insertInstructions.end());
|
|
||||||
instructions.insert(instructions.end(), downwardInstructions.begin(), downwardInstructions.end());
|
instructions.insert(instructions.end(), downwardInstructions.begin(), downwardInstructions.end());
|
||||||
|
instructions.insert(instructions.end(), insertInstructions.begin(), insertInstructions.end());
|
||||||
|
instructions.insert(instructions.end(), deleteInstructions.begin(), deleteInstructions.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void calculateMutationInstructions(
|
void calculateMutationInstructions(
|
||||||
TreeMutationInstructionList &instructions,
|
TreeMutationInstructionList &instructions,
|
||||||
SharedShadowNode oldRootShadowNode,
|
SharedShadowNode oldRootShadowNode,
|
||||||
|
|
Loading…
Reference in New Issue