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

@@ -52,6 +52,10 @@ import com.facebook.react.uimanager.annotations.ReactProp;
private int mMoveToIndexInParent;
private boolean mClipToBounds = false;
private boolean mIsUpdated = true;
private float mClipLeft;
private float mClipTop;
private float mClipRight;
private float mClipBottom;
// last OnLayoutEvent info, only used when shouldNotifyOnLayout() is true.
private int mLayoutX;
@@ -174,6 +178,26 @@ import com.facebook.react.uimanager.annotations.ReactProp;
mIsUpdated = false;
}
/* package */ final boolean clipBoundsChanged(
float clipLeft,
float clipTop,
float clipRight,
float clipBottom) {
return mClipLeft != clipLeft || mClipTop != clipTop ||
mClipRight != clipRight || mClipBottom != clipBottom;
}
/* package */ final void setClipBounds(
float clipLeft,
float clipTop,
float clipRight,
float clipBottom) {
mClipLeft = clipLeft;
mClipTop = clipTop;
mClipRight = clipRight;
mClipBottom = clipBottom;
}
/**
* Returns an array of DrawCommands to perform during the View's draw pass.
*/