From 03ac82e387a63ad78f284070e4984064ebea3e5f Mon Sep 17 00:00:00 2001 From: Andy Street Date: Mon, 21 Nov 2016 09:11:29 -0800 Subject: [PATCH] Recycle CSSNodes Summary: @public Adds a pool to recycle CSSNodes within UIManager. A follow-up diff will hook this up to a memory pressure listener to drop the pool on memory pressure. Reviewed By: emilsjolander Differential Revision: D4189532 --- .../com/facebook/react/flat/FlatUIImplementation.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index 0285ab161..42f9389bd 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -363,6 +363,11 @@ public class FlatUIImplementation extends UIImplementation { * and drops all Views used by it and its children. */ private void removeChild(ReactShadowNode child, ReactShadowNode parentNode) { + dropNativeViews(child, parentNode); + removeShadowNode(child); + } + + private void dropNativeViews(ReactShadowNode child, ReactShadowNode parentNode) { if (child instanceof FlatShadowNode) { FlatShadowNode node = (FlatShadowNode) child; if (node.mountsToView() && node.isBackingViewCreated()) { @@ -388,16 +393,13 @@ public class FlatUIImplementation extends UIImplementation { // this will recursively drop all subviews mStateBuilder.dropView(node, tag); - removeShadowNode(node); return; } } for (int i = 0, childCount = child.getChildCount(); i != childCount; ++i) { - removeChild(child.getChildAt(i), child); + dropNativeViews(child.getChildAt(i), child); } - - removeShadowNode(child); } /**