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

Unified Diff: include/private/SkChecksum.h

Issue 2208903002: Use sse4.2 CRC32 instructions to hash when available. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 4 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 | « gyp/opts.gypi ('k') | src/core/SkChecksum.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkChecksum.h
diff --git a/include/private/SkChecksum.h b/include/private/SkChecksum.h
index 6289a444ae78c3993f89a50e23cb14ec3f3d7b85..8a04c89ae79fac688759768fef5e6f1ea50fab8a 100644
--- a/include/private/SkChecksum.h
+++ b/include/private/SkChecksum.h
@@ -12,6 +12,12 @@
#include "SkTLogic.h"
#include "SkTypes.h"
+// #include "SkOpts.h"
+// It's sort of pesky to be able to include SkOpts.h here, so we'll just re-declare what we need.
+namespace SkOpts {
+ extern uint32_t (*hash_fn)(const void*, size_t, uint32_t);
+}
+
class SkChecksum : SkNoncopyable {
public:
/**
@@ -41,17 +47,6 @@ public:
hash ^= hash >> 16;
return hash;
}
-
- /**
- * Calculate 32-bit Murmur hash (murmur3).
- * See en.wikipedia.org/wiki/MurmurHash.
- *
- * @param data Memory address of the data block to be processed.
- * @param size Size of the data block in bytes.
- * @param seed Initial hash seed. (optional)
- * @return hash result
- */
- static uint32_t Murmur3(const void* data, size_t bytes, uint32_t seed=0);
};
// SkGoodHash should usually be your first choice in hashing data.
@@ -64,11 +59,11 @@ struct SkGoodHash {
template <typename K>
SK_WHEN(sizeof(K) != 4, uint32_t) operator()(const K& k) const {
- return SkChecksum::Murmur3(&k, sizeof(K));
+ return SkOpts::hash_fn(&k, sizeof(K), 0);
}
uint32_t operator()(const SkString& k) const {
- return SkChecksum::Murmur3(k.c_str(), k.size());
+ return SkOpts::hash_fn(k.c_str(), k.size(), 0);
}
};
« no previous file with comments | « gyp/opts.gypi ('k') | src/core/SkChecksum.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698