mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 20:37:31 +09:00
Issue #2928 - Avoid searching the image cache queue for an entry after we just popped it off the queue.
This commit is contained in:
parent
252cbabfd4
commit
3b799da2f8
2 changed files with 30 additions and 6 deletions
|
|
@ -1013,6 +1013,12 @@ imgCacheQueue::GetNumElements() const
|
||||||
return mQueue.size();
|
return mQueue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
imgCacheQueue::Contains(imgCacheEntry* aEntry) const
|
||||||
|
{
|
||||||
|
return mQueue.Contains(aEntry);
|
||||||
|
}
|
||||||
|
|
||||||
imgCacheQueue::iterator
|
imgCacheQueue::iterator
|
||||||
imgCacheQueue::begin()
|
imgCacheQueue::begin()
|
||||||
{
|
{
|
||||||
|
|
@ -1631,7 +1637,9 @@ imgLoader::CheckCacheLimits(imgCacheTable& cache, imgCacheQueue& queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
RemoveFromCache(entry);
|
// We just popped this entry from the queue, so pass AlreadyRemoved
|
||||||
|
// to avoid searching the queue again in RemoveFromCache.
|
||||||
|
RemoveFromCache(entry, QueueState::AlreadyRemoved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1930,7 +1938,7 @@ imgLoader::RemoveFromCache(const ImageCacheKey& aKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
imgLoader::RemoveFromCache(imgCacheEntry* entry)
|
imgLoader::RemoveFromCache(imgCacheEntry* entry, QueueState aQueueState)
|
||||||
{
|
{
|
||||||
LOG_STATIC_FUNC(gImgLog, "imgLoader::RemoveFromCache entry");
|
LOG_STATIC_FUNC(gImgLog, "imgLoader::RemoveFromCache entry");
|
||||||
|
|
||||||
|
|
@ -1944,6 +1952,8 @@ imgLoader::RemoveFromCache(imgCacheEntry* entry)
|
||||||
"imgLoader::RemoveFromCache", "entry's uri",
|
"imgLoader::RemoveFromCache", "entry's uri",
|
||||||
key.Spec());
|
key.Spec());
|
||||||
|
|
||||||
|
cache.Remove(key);
|
||||||
|
|
||||||
if (queue.IsDirty()) {
|
if (queue.IsDirty()) {
|
||||||
queue.Refresh();
|
queue.Refresh();
|
||||||
}
|
}
|
||||||
|
|
@ -1954,10 +1964,15 @@ imgLoader::RemoveFromCache(imgCacheEntry* entry)
|
||||||
if (mCacheTracker) {
|
if (mCacheTracker) {
|
||||||
mCacheTracker->RemoveObject(entry);
|
mCacheTracker->RemoveObject(entry);
|
||||||
}
|
}
|
||||||
|
// Only search the queue to remove the entry if its possible it might
|
||||||
|
// be in the queue. If we know its not in the queue this would be
|
||||||
|
// wasted work.
|
||||||
|
MOZ_ASSERT_IF(aQueueState == QueueState::AlreadyRemoved,
|
||||||
|
!queue.Contains(entry));
|
||||||
|
if (aQueueState == QueueState::MaybeExists) {
|
||||||
queue.Remove(entry);
|
queue.Remove(entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cache.Remove(key);
|
|
||||||
|
|
||||||
entry->SetEvicted(true);
|
entry->SetEvicted(true);
|
||||||
request->SetIsInCache(false);
|
request->SetIsInCache(false);
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,16 @@ public:
|
||||||
nsresult InitCache();
|
nsresult InitCache();
|
||||||
|
|
||||||
bool RemoveFromCache(const ImageCacheKey& aKey);
|
bool RemoveFromCache(const ImageCacheKey& aKey);
|
||||||
bool RemoveFromCache(imgCacheEntry* entry);
|
|
||||||
|
// Enumeration describing if a given entry is in the cache queue or not.
|
||||||
|
// There are some cases we know the entry is definitely not in the queue.
|
||||||
|
enum class QueueState {
|
||||||
|
MaybeExists,
|
||||||
|
AlreadyRemoved
|
||||||
|
};
|
||||||
|
|
||||||
|
bool RemoveFromCache(imgCacheEntry* entry,
|
||||||
|
QueueState aQueueState = QueueState::MaybeExists);
|
||||||
|
|
||||||
bool PutIntoCache(const ImageCacheKey& aKey, imgCacheEntry* aEntry);
|
bool PutIntoCache(const ImageCacheKey& aKey, imgCacheEntry* aEntry);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue