mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-07 22:40:55 +08:00
Use SparseArray for detached views.
Summary: This is minor, but for our use case a SparseArray is going to be faster as long as we have less than 10,000 clipped subviews, and will also use much less memory. Faster because of the boxing, unboxing and hash caching; less memory as it is two arrays instead of the object overhead of the HashMap. Reviewed By: ahmedre Differential Revision: D3704326
This commit is contained in:
committed by
Ahmed El-Helw
parent
b2f41e2921
commit
a602891946
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
@@ -208,8 +209,9 @@ import com.facebook.react.uimanager.ViewManagerRegistry;
|
||||
if (view instanceof FlatViewGroup) {
|
||||
FlatViewGroup flatViewGroup = (FlatViewGroup) view;
|
||||
if (flatViewGroup.getRemoveClippedSubviews()) {
|
||||
Collection<View> detachedViews = flatViewGroup.getDetachedViews();
|
||||
for (View detachedChild : detachedViews) {
|
||||
SparseArray<View> detachedViews = flatViewGroup.getDetachedViews();
|
||||
for (int i = 0, size = detachedViews.size(); i < size; i++) {
|
||||
View detachedChild = detachedViews.valueAt(i);
|
||||
// we can do super here because removeClippedSubviews is currently not recursive. if/when
|
||||
// we become recursive one day, this should call vanilla dropView to be recursive as well.
|
||||
super.dropView(detachedChild);
|
||||
|
||||
Reference in New Issue
Block a user