Only collect state from nodes that have been updated

Summary: We are currently traversing entire tree every time there is any update to any of the nodes, which is hugely inefficient. Instead, we can early out for nodes that are known to contain no updates. This saves a lof of CPU. This optimization can be turned off, and an Exception will be thrown if there was an unexpected update.

Reviewed By: ahmedre

Differential Revision: D2975706
This commit is contained in:
Denis Koroskin
2016-02-25 20:38:01 -08:00
committed by Ahmed El-Helw
parent 7055c52288
commit 42fb9a3d91
3 changed files with 64 additions and 19 deletions

View File

@@ -402,23 +402,13 @@ public class FlatUIImplementation extends UIImplementation {
parentNode.addChildAt(childNode, index);
}
@Override
protected void calculateRootLayout(ReactShadowNode cssRoot) {
}
@Override
protected void applyUpdatesRecursive(
ReactShadowNode cssNode,
float absoluteX,
float absoluteY,
EventDispatcher eventDispatcher) {
FlatRootShadowNode rootNode = (FlatRootShadowNode) cssNode;
if (!rootNode.needsLayout() && !rootNode.isUpdated()) {
return;
}
super.calculateRootLayout(rootNode);
mStateBuilder.applyUpdates(eventDispatcher, rootNode);
mStateBuilder.applyUpdates(eventDispatcher, (FlatRootShadowNode) cssNode);
}
@Override