From 9b97c09612050420557f2eca8391999e2fea1ca0 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 17 Sep 2021 07:19:22 -0700 Subject: [PATCH] Short-circuit evaluation of formsView Summary: Changelog: [Internal] Small optimization, we can avoid evaluating some properties if `formsStackingContext` is already set, because the end-result is always true. Reviewed By: sammy-SC Differential Revision: D30990925 fbshipit-source-id: 08f500aa4b75446a6c644e8821f84dbfccbfebb6 --- .../react/renderer/components/view/ViewShadowNode.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp b/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp index cba3969fe3149f..75fa7f4c73a6a2 100644 --- a/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp @@ -46,13 +46,12 @@ void ViewShadowNode::initialize() noexcept { viewProps.importantForAccessibility != ImportantForAccessibility::Auto || viewProps.removeClippedSubviews; - bool formsView = isColorMeaningful(viewProps.backgroundColor) || + bool formsView = formsStackingContext || + isColorMeaningful(viewProps.backgroundColor) || isColorMeaningful(viewProps.foregroundColor) || !(viewProps.yogaStyle.border() == YGStyle::Edges{}) || !viewProps.testId.empty(); - formsView = formsView || formsStackingContext; - if (formsView) { traits_.set(ShadowNodeTraits::Trait::FormsView); } else {