Bug 411061 nsAutoTArray uses an inefficient first-time allocation strategy r=bsmedberg a=schrep

This commit is contained in:
neil%parkwaycc.co.uk 2008-01-19 13:47:46 +00:00
Родитель 0998c7390f
Коммит 3699446778
1 изменённых файлов: 1 добавлений и 5 удалений

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

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