From 16499c108651cef7ca2d0168d277e773f51f3b25 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 10 May 2019 15:31:00 -0700 Subject: [PATCH] Fabric: Removing of all unnececery nil checks in RCTMountingManager Summary: We needed that in the very beginning when diffing algorithm produces mount instructions for nodes which don't have ComponentView representation, so we simply silence those error here. That's not the case anymore, so we don't need those ugly checks. Reviewed By: JoshuaGross Differential Revision: D15296473 fbshipit-source-id: ea3717062056907e5395776fe95e3d581d3e9b09 --- React/Fabric/Mounting/RCTMountingManager.mm | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index 9636100dc2e..bf781fea21b 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -36,10 +36,7 @@ static void RNDeleteMountInstruction(ShadowViewMutation const &mutation, RCTComp auto const &oldChildShadowView = mutation.oldChildShadowView; UIView *componentView = [registry componentViewByTag:oldChildShadowView.tag]; - // TODO(shergin): Make sure that we don't need this check anymore and delete it. - if (componentView == nil) { - return; - } + assert(componentView != nil && "Attempt to delete unregistered component."); [registry enqueueComponentViewWithComponentHandle:oldChildShadowView.componentHandle tag:oldChildShadowView.tag @@ -55,10 +52,8 @@ static void RNInsertMountInstruction(ShadowViewMutation const &mutation, RCTComp UIView *childComponentView = [registry componentViewByTag:newShadowView.tag]; UIView *parentComponentView = [registry componentViewByTag:parentShadowView.tag]; - // TODO(shergin): Make sure that we don't need this check anymore and delete it. - if (childComponentView == nil || parentComponentView == nil) { - return; - } + assert(childComponentView != nil && "Attempt to mount unregistered component."); + assert(parentComponentView != nil && "Attempt to mount into unregistered component."); [parentComponentView mountChildComponentView:childComponentView index:mutation.index]; } @@ -72,10 +67,8 @@ static void RNRemoveMountInstruction(ShadowViewMutation const &mutation, RCTComp UIView *childComponentView = [registry componentViewByTag:oldShadowView.tag]; UIView *parentComponentView = [registry componentViewByTag:parentShadowView.tag]; - // TODO(shergin): Make sure that we don't need this check anymore and delete it. - if (childComponentView == nil || parentComponentView == nil) { - return; - } + assert(childComponentView != nil && "Attempt to unmount unregistered component."); + assert(parentComponentView != nil && "Attempt to unmount from unregistered component."); [parentComponentView unmountChildComponentView:childComponentView index:mutation.index]; }