mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-09 17:56:37 +08:00
c168ce4e76
* [antlr4] Update to 4.10.1 * x-add-version * update portfile.cmake * x-add-version Co-authored-by: LilyWangLL <v-lilywang@microsoft.com>
51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
diff --git a/runtime/src/misc/MurmurHash.cpp b/runtime/src/misc/MurmurHash.cpp
|
|
index 73562cd..57aa3bf 100644
|
|
--- a/runtime/src/misc/MurmurHash.cpp
|
|
+++ b/runtime/src/misc/MurmurHash.cpp
|
|
@@ -63,23 +63,6 @@ size_t MurmurHash::update(size_t hash, size_t value) {
|
|
return hash;
|
|
}
|
|
|
|
-size_t MurmurHash::update(size_t hash, const void *data, size_t size) {
|
|
- size_t value;
|
|
- const uint8_t *bytes = static_cast<const uint8_t*>(data);
|
|
- while (size >= sizeof(size_t)) {
|
|
- std::memcpy(&value, bytes, sizeof(size_t));
|
|
- hash = update(hash, value);
|
|
- bytes += sizeof(size_t);
|
|
- size -= sizeof(size_t);
|
|
- }
|
|
- if (size != 0) {
|
|
- value = 0;
|
|
- std::memcpy(&value, bytes, size);
|
|
- hash = update(hash, value);
|
|
- }
|
|
- return hash;
|
|
-}
|
|
-
|
|
size_t MurmurHash::finish(size_t hash, size_t entryCount) {
|
|
hash ^= entryCount * 8;
|
|
hash ^= hash >> 33;
|
|
@@ -118,3 +101,20 @@ size_t MurmurHash::finish(size_t hash, size_t entryCount) {
|
|
#else
|
|
#error "Expected sizeof(size_t) to be 4 or 8."
|
|
#endif
|
|
+
|
|
+size_t MurmurHash::update(size_t hash, const void *data, size_t size) {
|
|
+ size_t value;
|
|
+ const uint8_t *bytes = static_cast<const uint8_t*>(data);
|
|
+ while (size >= sizeof(size_t)) {
|
|
+ std::memcpy(&value, bytes, sizeof(size_t));
|
|
+ hash = update(hash, value);
|
|
+ bytes += sizeof(size_t);
|
|
+ size -= sizeof(size_t);
|
|
+ }
|
|
+ if (size != 0) {
|
|
+ value = 0;
|
|
+ std::memcpy(&value, bytes, size);
|
|
+ hash = update(hash, value);
|
|
+ }
|
|
+ return hash;
|
|
+}
|
|
\ No newline at end of file
|