Do not preallocate memory in default constructor of Sparse.*Array
By heapdump examination this saves not-an-insignificant amount of memory and significant amount of allocations. Similar change was also introduced for ArrayList & HashMap implementation in JDK8. More details in go/if-xr-android-util-collections-lazy-init. Bug: 272467748 Test: Verified system server heapdump Change-Id: I849dbaa46e79eae0b61b93a7ab1f5d5ef8bfbf7f
This commit is contained in:
committed by
Ján Sebechlebský
parent
a27edf5a52
commit
333d9757d2
@@ -71,7 +71,7 @@ public class SparseArray<E> implements Cloneable {
|
||||
* Creates a new SparseArray containing no mappings.
|
||||
*/
|
||||
public SparseArray() {
|
||||
this(10);
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SparseBooleanArray implements Cloneable {
|
||||
* Creates a new SparseBooleanArray containing no mappings.
|
||||
*/
|
||||
public SparseBooleanArray() {
|
||||
this(10);
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SparseDoubleArray implements Cloneable {
|
||||
|
||||
/** Creates a new SparseDoubleArray containing no mappings. */
|
||||
public SparseDoubleArray() {
|
||||
this(10);
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SparseIntArray implements Cloneable {
|
||||
* Creates a new SparseIntArray containing no mappings.
|
||||
*/
|
||||
public SparseIntArray() {
|
||||
this(10);
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SparseLongArray implements Cloneable {
|
||||
* Creates a new SparseLongArray containing no mappings.
|
||||
*/
|
||||
public SparseLongArray() {
|
||||
this(10);
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user