Store MemoryCache's live decoded resources in a ListHashSet
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jan 2015 17:40:51 +0000 (17:40 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jan 2015 17:40:51 +0000 (17:40 +0000)
commit6177937a445f136bb50609bfa0ff79233dfaf22f
tree42c1449d992ffe4ed6126f672a1f67ee7ba03743
parent44b6bded069694c5f51bed7052ce585f41ff5e05
Store MemoryCache's live decoded resources in a ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=141051

Reviewed by Antti Koivisto.

Store MemoryCache's live decoded resources in a ListHashSet instead of
a linked list. The frequent operations are:
1. Add items to one end
2. Remove items from the other end or anywhere in the container by value

Using a ListHashSet instead of a manual linked list results in *much*
simpler / shorter code and is fast for all operations (faster than
linked list even for removing an given element from the container given
its value). The previous implementation required us to keep a lot of
pointers up-to-date, which was error prone.

This is a first step towards simplifying the MemoryCache implementation.

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::setDecodedSize):
(WebCore::CachedResource::didAccessDecodedData):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::inLiveDecodedResourcesList): Deleted.
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::pruneLiveResourcesToSize):
(WebCore::MemoryCache::removeFromLiveDecodedResourcesList):
(WebCore::MemoryCache::insertInLiveDecodedResourcesList):
* loader/cache/MemoryCache.h:
(WebCore::MemoryCache::inLiveDecodedResourcesList):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179402 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/loader/cache/MemoryCache.h