From 298a3f947b4d3474e0b2c7f8041d5f20916ef4cf Mon Sep 17 00:00:00 2001 From: Seth Kirby Date: Fri, 24 Jun 2016 11:58:00 -0700 Subject: [PATCH] Remove unnecessary view mounting when views are clipped. Summary: Reduced view attaching by 93% in mountViews. Reviewed By: ahmedre Differential Revision: D3477555 --- .../java/com/facebook/react/flat/FlatViewGroup.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java index 0d64f58d6..419d54699 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java @@ -492,13 +492,14 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper; addViewInLayout(view, -1, ensureLayoutParams(view.getLayoutParams()), true); } else { View view = ensureViewHasNoParent(viewResolver.getView(-viewToAdd)); - attachViewToParent(view, -1, ensureLayoutParams(view.getLayoutParams())); if (mRemoveClippedSubviews) { - mClippedSubviews.remove(-viewToAdd); - DrawView drawView = mDrawViewMap.get(-viewToAdd); - if (drawView != null) { - drawView.isViewGroupClipped = false; + DrawView drawView = Assertions.assertNotNull(mDrawViewMap.get(-viewToAdd)); + // If the view is clipped, we don't need to attach it. + if (!drawView.isViewGroupClipped) { + attachViewToParent(view, -1, ensureLayoutParams(view.getLayoutParams())); } + } else { + attachViewToParent(view, -1, ensureLayoutParams(view.getLayoutParams())); } } }