Some usability ideas around SkTHash.
- By default, use new SkGoodHash to hash keys, which is:
* for 4 byte values, use SkChecksum::Mix,
* for SkStrings, use SkChecksum::Murmur3 on the data,
* for other structs, shallow hash the struct with Murmur3.
- Expand SkChecksum::Murmur3 to support non-4-byte-aligned data.
- Add const foreach() methods.
- Have foreach() take a functor, which allows lambdas.
BUG=skia:
Review URL: https://codereview.chromium.org/1021033002
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 109a00d..833af0e 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -104,13 +104,8 @@
this->append(src);
this->append(name);
this->append(md5);
- while (this->size() % 4) {
- this->append("!"); // Pad out if needed so we can pass this to Murmur3.
- }
}
- static uint32_t Hash(const Gold& g) {
- return SkChecksum::Murmur3((const uint32_t*)g.c_str(), g.size());
- }
+ static uint32_t Hash(const Gold& g) { return SkGoodHash((const SkString&)g); }
};
static SkTHashSet<Gold, Gold::Hash> gGold;