mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-06 09:31:11 +08:00
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:
committed by
Ahmed El-Helw
parent
7055c52288
commit
42fb9a3d91
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user