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

Unified Diff: include/private/SkTHash.h

Issue 1405053002: SkTHash: hash from fnptr to functor type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « include/private/SkChecksum.h ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkTHash.h
diff --git a/include/private/SkTHash.h b/include/private/SkTHash.h
index 53d52754bd36340db546c92b0d8309f90cdee5f2..8a644e3b019750a768c806934f9635925b3e0f6b 100644
--- a/include/private/SkTHash.h
+++ b/include/private/SkTHash.h
@@ -191,7 +191,7 @@ private:
// Maps K->V. A more user-friendly wrapper around SkTHashTable, suitable for most use cases.
// K and V are treated as ordinary copyable C++ types, with no assumed relationship between the two.
-template <typename K, typename V, uint32_t(*HashK)(const K&) = &SkGoodHash>
+template <typename K, typename V, typename HashK = SkGoodHash>
class SkTHashMap : SkNoncopyable {
public:
SkTHashMap() {}
@@ -247,14 +247,14 @@ private:
K key;
V val;
static const K& GetKey(const Pair& p) { return p.key; }
- static uint32_t Hash(const K& key) { return HashK(key); }
+ static uint32_t Hash(const K& key) { return HashK()(key); }
};
SkTHashTable<Pair, K> fTable;
};
// A set of T. T is treated as an ordiary copyable C++ type.
-template <typename T, uint32_t(*HashT)(const T&) = &SkGoodHash>
+template <typename T, typename HashT = SkGoodHash>
class SkTHashSet : SkNoncopyable {
public:
SkTHashSet() {}
@@ -293,7 +293,7 @@ public:
private:
struct Traits {
static const T& GetKey(const T& item) { return item; }
- static uint32_t Hash(const T& item) { return HashT(item); }
+ static uint32_t Hash(const T& item) { return HashT()(item); }
};
SkTHashTable<T, T, Traits> fTable;
};
« no previous file with comments | « include/private/SkChecksum.h ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698