don't null out array in ArrayList when size goes to zero

This avoids thrashing in the case of a list which is frequently
emptied and refilled with a small number of elements.
This commit is contained in:
Joel Dice 2009-11-19 11:43:11 -07:00
parent c711ac5701
commit adcac443e4

View File

@ -38,8 +38,6 @@ public class ArrayList<T> extends AbstractList<T> {
private void shrink() {
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
resize(array.length / 2);
} else if (size == 0) {
resize(0);
}
}