Avoid emitting mountitems for default values

Summary:
Noticed that we emit a large amount of (admittedly cheap) mountitems as part of node creation for values that are all zero (e.g. padding, overflowinset), which we can assume to be already initialised with these values on the native side.

There's a further opportunity to do this for State as well, as ReactImageComponentState exports just empty maps to Java.

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36345402

fbshipit-source-id: 8d776ca124bdb9e1cd4de57a04e2785a9a0f918c
This commit is contained in:
Pieter De Baets
2022-05-18 05:44:11 -07:00
committed by Facebook GitHub Bot
parent 8a8c33aab9
commit 56e9aa369f
2 changed files with 14 additions and 6 deletions
@@ -421,20 +421,23 @@ void FabricMountingManager::executeMount(
// are updated in the view. This is necessary to ensure that events
// (resulting from layout changes) are dispatched with the correct
// padding information.
cppUpdatePaddingMountItems.push_back(
CppMountItem::UpdatePaddingMountItem(
mutation.newChildShadowView));
if (newChildShadowView.layoutMetrics.contentInsets !=
EdgeInsets::ZERO) {
cppUpdatePaddingMountItems.push_back(
CppMountItem::UpdatePaddingMountItem(newChildShadowView));
}
// Layout
cppUpdateLayoutMountItems.push_back(
CppMountItem::UpdateLayoutMountItem(
mutation.newChildShadowView));
CppMountItem::UpdateLayoutMountItem(newChildShadowView));
// OverflowInset: This is the values indicating boundaries including
// children of the current view. The layout of current view may not
// change, and we separate this part from layout mount items to not
// pack too much data there.
if (useOverflowInset_) {
if (useOverflowInset_ &&
newChildShadowView.layoutMetrics.overflowInset !=
EdgeInsets::ZERO) {
cppUpdateOverflowInsetMountItems.push_back(
CppMountItem::UpdateOverflowInsetMountItem(
newChildShadowView));