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/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index 45e616b..8d2f18a 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -103,12 +103,6 @@
return tstr;
}
-uint32_t hash_family_string(const SkString& family) {
- // This is a lame hash function, but we don't really expect to see more than 1-2
- // family names under normal circumstances.
- return SkChecksum::Mix(SkToU32(family.size()));
-}
-
struct Resources {
Resources(const SkPaint& paint)
: fPaintServer(svg_color(paint.getColor())) {}
@@ -538,7 +532,7 @@
}
SkString familyName;
- SkTHashSet<SkString, hash_family_string> familySet;
+ SkTHashSet<SkString> familySet;
SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ?
SkRef(paint.getTypeface()) : SkTypeface::RefDefault());