From 03637dc70d2bc623af5ae9e282631ca5b2f7dc9b Mon Sep 17 00:00:00 2001 From: Denis Koroskin Date: Mon, 11 Jan 2016 20:03:21 -0800 Subject: [PATCH] Don't add empty NodeRegion, because it will never receive touch events anyway Summary: Small optimization that prevents empty NodeRegions from being collected. Those will never receive touch events anyway, so why bother allocating memory and iterating over them? Reviewed By: ahmedre Differential Revision: D2816355 --- .../src/main/java/com/facebook/react/flat/StateBuilder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java index 1a9f1b605..c6c0f64d4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java @@ -150,6 +150,11 @@ import com.facebook.react.uimanager.events.EventDispatcher; float top, float right, float bottom) { + if (left == right || top == bottom) { + // no point in adding an empty NodeRegion + return; + } + node.updateNodeRegion(left, top, right, bottom); mNodeRegions.add(node.getNodeRegion()); }