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
parent 7215329de9
commit 716ba038a6

View File

@ -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])) {