Skip to content

Commit

Permalink
Short-circuit evaluation of formsView
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javache authored and facebook-github-bot committed Sep 17, 2021
1 parent dd10134 commit 9b97c09
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ReactCommon/react/renderer/components/view/ViewShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9b97c09

Please sign in to comment.