From fc0b03a0d11efdc98e34298e67ab1258a611c3ca Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 11 Sep 2019 18:27:01 -0700 Subject: [PATCH] Fabric: Small perfromance optimization in `[RCTViewComponentView updateLayoutMetrics:oldLayoutMetrics:]` Summary: Before this change, we reapply all layout props for all newly mounted views (on `insert` instruction), now we use stored `_layoutMetrics` value to apply only changed subset. This is only available for `RCTViewComponentView` subclasses (where we have an ability to store a previous value), all other implementation of `RCTComponentViewProtocol` will work as usual. Reviewed By: JoshuaGross, sammy-SC Differential Revision: D17312175 fbshipit-source-id: b202583c0c58987876d906b748ef3a749f8dad70 --- .../Mounting/ComponentViews/View/RCTViewComponentView.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 8c67f8f0457..fa203484ae1 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -252,7 +252,9 @@ using namespace facebook::react; - (void)updateLayoutMetrics:(LayoutMetrics const &)layoutMetrics oldLayoutMetrics:(LayoutMetrics const &)oldLayoutMetrics { - [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics]; + // Using stored `_layoutMetrics` as `oldLayoutMetrics` here to avoid + // re-applying individual sub-values which weren't changed. + [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:_layoutMetrics]; _layoutMetrics = layoutMetrics; _needsInvalidateLayer = YES;