xref: /aosp_15_r20/external/libchrome/libchrome_tools/patch/hash.patch (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker# libchrome does not support SuperFastHash. Instead use std::hash.
2*635a8641SAndroid Build Coastguard Worker
3*635a8641SAndroid Build Coastguard Worker--- a/base/hash.cc
4*635a8641SAndroid Build Coastguard Worker+++ b/base/hash.cc
5*635a8641SAndroid Build Coastguard Worker@@ -4,10 +4,12 @@
6*635a8641SAndroid Build Coastguard Worker
7*635a8641SAndroid Build Coastguard Worker #include "base/hash.h"
8*635a8641SAndroid Build Coastguard Worker
9*635a8641SAndroid Build Coastguard Worker-// Definition in base/third_party/superfasthash/superfasthash.c. (Third-party
10*635a8641SAndroid Build Coastguard Worker-// code did not come with its own header file, so declaring the function here.)
11*635a8641SAndroid Build Coastguard Worker-// Note: This algorithm is also in Blink under Source/wtf/StringHasher.h.
12*635a8641SAndroid Build Coastguard Worker-extern "C" uint32_t SuperFastHash(const char* data, int len);
13*635a8641SAndroid Build Coastguard Worker+#include <functional>
14*635a8641SAndroid Build Coastguard Worker+
15*635a8641SAndroid Build Coastguard Worker+uint32_t SuperFastHash(const char* data, size_t len) {
16*635a8641SAndroid Build Coastguard Worker+  std::hash<std::string> hash_fn;
17*635a8641SAndroid Build Coastguard Worker+  return hash_fn(std::string(data, len));
18*635a8641SAndroid Build Coastguard Worker+}
19*635a8641SAndroid Build Coastguard Worker
20*635a8641SAndroid Build Coastguard Worker namespace base {
21*635a8641SAndroid Build Coastguard Worker
22