diff --git a/xpcom/glue/nsTArray.cpp b/xpcom/glue/nsTArray.cpp index 424558f4ef4..e20d4f58356 100644 --- a/xpcom/glue/nsTArray.cpp +++ b/xpcom/glue/nsTArray.cpp @@ -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()) {