Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: src/core/SkResourceCache.cpp

Issue 567303002: remove 'experimental' from using hash tables in resourcecache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkResourceCache.cpp
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index 9262c3476fe4e0bc1d6ebb246d6de19e283189f0..68248f512bd2f08e4575e06d916e462750578d1f 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -37,28 +37,10 @@ class SkResourceCache::Hash :
///////////////////////////////////////////////////////////////////////////////
-// experimental hash to speed things up
-#define USE_HASH
-
-#if !defined(USE_HASH)
-static inline SkResourceCache::Rec* find_rec_in_list(
- SkResourceCache::Rec* head, const Key & key) {
- SkResourceCache::Rec* rec = head;
- while ((rec != NULL) && (rec->fKey != key)) {
- rec = rec->fNext;
- }
- return rec;
-}
-#endif
-
void SkResourceCache::init() {
fHead = NULL;
fTail = NULL;
-#ifdef USE_HASH
fHash = new Hash;
-#else
- fHash = NULL;
-#endif
fTotalBytesUsed = 0;
fCount = 0;
fSingleAllocationByteLimit = 0;
@@ -206,11 +188,7 @@ SkResourceCache::~SkResourceCache() {
////////////////////////////////////////////////////////////////////////////////
const SkResourceCache::Rec* SkResourceCache::findAndLock(const Key& key) {
-#ifdef USE_HASH
Rec* rec = fHash->find(key);
-#else
- Rec* rec = find_rec_in_list(fHead, key);
-#endif
if (rec) {
this->moveToHead(rec); // for our LRU
rec->fLockCount += 1;
@@ -229,10 +207,7 @@ const SkResourceCache::Rec* SkResourceCache::addAndLock(Rec* rec) {
this->addToHead(rec);
SkASSERT(1 == rec->fLockCount);
-#ifdef USE_HASH
- SkASSERT(fHash);
fHash->add(rec);
-#endif
// We may (now) be overbudget, so see if we need to purge something.
this->purgeAsNeeded();
return rec;
@@ -250,10 +225,7 @@ void SkResourceCache::add(Rec* rec) {
this->addToHead(rec);
SkASSERT(1 == rec->fLockCount);
-#ifdef USE_HASH
- SkASSERT(fHash);
fHash->add(rec);
-#endif
this->unlock(rec);
}
@@ -293,9 +265,7 @@ void SkResourceCache::remove(Rec* rec) {
SkASSERT(used <= fTotalBytesUsed);
this->detach(rec);
-#ifdef USE_HASH
fHash->remove(rec->getKey());
-#endif
SkDELETE(rec);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698