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:
Seth Kirby
2016-08-15 20:39:50 -07:00
committed by Ahmed El-Helw
parent b2f41e2921
commit a602891946
4 changed files with 14 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ import java.util.Collection;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewParent;
@@ -78,7 +79,7 @@ import android.view.ViewParent;
*
* @return A collection of the currently detached views.
*/
abstract Collection<View> getDetachedViews();
abstract SparseArray<View> getDetachedViews();
/**
* Draw the relevant items. This should do as little work as possible.