Bug 1187149 - Replace nsBaseHashtable::Enumerate() calls in image/ with iterators r=njn

This commit is contained in:
Sotaro Ikeda 2015-11-10 21:30:02 -08:00
Родитель ad0dd8414a
Коммит 7246d92be6
1 изменённых файлов: 4 добавлений и 14 удалений

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

@ -1903,19 +1903,6 @@ imgLoader::RemoveFromCache(imgCacheEntry* entry)
return false;
}
static PLDHashOperator
EnumEvictEntries(const ImageCacheKey&,
RefPtr<imgCacheEntry>& aData,
void* data)
{
nsTArray<RefPtr<imgCacheEntry> >* entries =
reinterpret_cast<nsTArray<RefPtr<imgCacheEntry> > *>(data);
entries->AppendElement(aData);
return PL_DHASH_NEXT;
}
nsresult
imgLoader::EvictEntries(imgCacheTable& aCacheToClear)
{
@ -1924,7 +1911,10 @@ imgLoader::EvictEntries(imgCacheTable& aCacheToClear)
// We have to make a temporary, since RemoveFromCache removes the element
// from the queue, invalidating iterators.
nsTArray<RefPtr<imgCacheEntry> > entries;
aCacheToClear.Enumerate(EnumEvictEntries, &entries);
for (auto iter = aCacheToClear.Iter(); !iter.Done(); iter.Next()) {
RefPtr<imgCacheEntry>& data = iter.Data();
entries.AppendElement(data);
}
for (uint32_t i = 0; i < entries.Length(); ++i) {
if (!RemoveFromCache(entries[i])) {