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

Unified Diff: src/core/SkTDynamicHash.h

Issue 222473002: SkTDynamicHash: pick up GetKey(), Hash() from T by default. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 9 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 | « src/core/SkScaledImageCache.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTDynamicHash.h
diff --git a/src/core/SkTDynamicHash.h b/src/core/SkTDynamicHash.h
index 0e34270e0b459765f705405e85106706c48a9a9d..c9a0b3ed01cfaa24cb3851f8fe9cd5c2125af2dd 100644
--- a/src/core/SkTDynamicHash.h
+++ b/src/core/SkTDynamicHash.h
@@ -12,10 +12,13 @@
#include "SkTemplates.h"
#include "SkTypes.h"
+// Traits requires:
+// static const Key& GetKey(const T&) { ... }
+// static uint32_t Hash(const Key&) { ... }
+// We'll look on T for these by default, or you can pass a custom Traits type.
template <typename T,
typename Key,
- const Key& (GetKey)(const T&),
- uint32_t (Hash)(const Key&),
+ typename Traits = T,
int kGrowPercent = 75> // Larger -> more memory efficient, but slower.
class SkTDynamicHash {
public:
@@ -227,6 +230,9 @@ private:
return (index + round + 1) & this->hashMask();
}
+ static const Key& GetKey(const T& t) { return Traits::GetKey(t); }
+ static uint32_t Hash(const Key& key) { return Traits::Hash(key); }
+
int fCount; // Number of non Empty(), non Deleted() entries in fArray.
int fDeleted; // Number of Deleted() entries in fArray.
int fCapacity; // Number of entries in fArray. Always a power of 2.
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698