test growing the array by a minimum amount (taken from nsVoidArray).

This commit is contained in:
dwitte%stanford.edu 2007-12-19 09:56:28 +00:00
Родитель f190360d35
Коммит 4fd8d3cb81
1 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -84,10 +84,15 @@ nsTArray_base::EnsureCapacity(size_type capacity, size_type elemSize) {
// Use doubling algorithm when forced to increase available capacity.
NS_ASSERTION(mHdr->mCapacity > 0, "should not have buffer of zero size");
size_type temp = mHdr->mCapacity;
while (temp < capacity)
temp <<= 1;
capacity = temp;
if (capacity < 8) {
// grow to 8 elements
capacity = 8;
} else {
size_type temp = mHdr->mCapacity;
while (temp < capacity)
temp <<= 1;
capacity = temp;
}
Header *header;
if (UsesAutoArrayBuffer()) {