Bug 1383404 - Part 3. SourceBuffer::mChunks should be an AutoTArray instead of FallibleTArray. r=tnikkel

We should use AutoTArray instead because telemetry shows that the vast
majority of images loaded (95%+) contain only a single chunk when
decoding finishes. Even if part 2 of this bug increases the number of
images loaded with multiple chunks, we still call SourceBuffer::Compact
after the decode is complete, which typically will reduce the number of
chunks to 1 (unless memory is very low and we fail to consolidate the
chunks). Thus it should be rare to contain more than 1 chunk on
anything but a temporary basis, and we can easily save the malloc
overhead.

Note that SourceBuffer::AppendChunk still uses the fallible variant of
nsTArray::AppendElement.
This commit is contained in:
Andrew Osmond 2017-08-01 06:59:11 -04:00
Родитель f072d8f9e8
Коммит af89f9b9b6
1 изменённых файлов: 1 добавлений и 1 удалений

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

@ -494,7 +494,7 @@ private:
mutable Mutex mMutex;
/// The data in this SourceBuffer, stored as a series of Chunks.
FallibleTArray<Chunk> mChunks;
AutoTArray<Chunk, 1> mChunks;
/// Consumers which are waiting to be notified when new data is available.
nsTArray<RefPtr<IResumable>> mWaitingConsumers;