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
This commit is contained in:
Valentin Shergin
2019-09-11 18:29:22 -07:00
committed by Facebook Github Bot
parent fc9c53d621
commit fc0b03a0d1
@@ -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;