From 184eb172616f4456a9fbc09cf1c912a83dd56dbb Mon Sep 17 00:00:00 2001 From: Thomas Nardone Date: Thu, 14 Nov 2024 09:16:43 -0800 Subject: [PATCH] ReactViewGroup - remove sHelperRect (#47588) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47588 This is unnecessary - we can pass the params directly instead of first populating them in a Rect. Changelog: [Internal] Reviewed By: rshest Differential Revision: D65843834 fbshipit-source-id: 92bb3faa622bba81792fe92e357bc1667894d4ef --- .../com/facebook/react/views/view/ReactViewGroup.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index 6c33e2ee70e2ad..3396c6b3af46eb 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -77,8 +77,6 @@ public class ReactViewGroup extends ViewGroup private static final int DEFAULT_BACKGROUND_COLOR = Color.TRANSPARENT; private static final LayoutParams sDefaultLayoutParam = new ViewGroup.LayoutParams(0, 0); private final Rect mOverflowInset = new Rect(); - /* should only be used in {@link #updateClippingToRect} */ - private static final Rect sHelperRect = new Rect(); /** * This listener will be set for child views when removeClippedSubview property is enabled. When @@ -192,7 +190,6 @@ private void initView() { // Set default field values initView(); mOverflowInset.setEmpty(); - sHelperRect.setEmpty(); // Remove any children removeAllViews(); @@ -443,10 +440,9 @@ private void updateSubviewClipStatus(Rect clippingRect, int idx, int clippedSoFa UiThreadUtil.assertOnUiThread(); View child = Assertions.assertNotNull(mAllChildren)[idx]; - sHelperRect.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); boolean intersects = clippingRect.intersects( - sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom); + child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); boolean needUpdateClippingRecursive = false; // We never want to clip children that are being animated, as this can easily break layout : // when layout animation changes size and/or position of views contained inside a listview that @@ -471,8 +467,6 @@ private void updateSubviewClipStatus(Rect clippingRect, int idx, int clippedSoFa } if (needUpdateClippingRecursive) { if (child instanceof ReactClippingViewGroup) { - // we don't use {@link sHelperRect} until the end of this loop, therefore it's safe - // to call this method that may write to the same {@link sHelperRect} object. ReactClippingViewGroup clippingChild = (ReactClippingViewGroup) child; if (clippingChild.getRemoveClippedSubviews()) { clippingChild.updateClippingRect(); @@ -490,10 +484,9 @@ private void updateSubviewClipStatus(View subview) { Assertions.assertNotNull(mAllChildren); // do fast check whether intersect state changed - sHelperRect.set(subview.getLeft(), subview.getTop(), subview.getRight(), subview.getBottom()); boolean intersects = mClippingRect.intersects( - sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom); + subview.getLeft(), subview.getTop(), subview.getRight(), subview.getBottom()); // If it was intersecting before, should be attached to the parent boolean oldIntersects = (subview.getParent() != null);