diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2021-12-10 12:47:03 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2022-01-01 10:36:38 -0800 |
| commit | 2652aed85c0ab0ee9d51cfd5065b4bb4a620ab45 (patch) | |
| tree | 468fca3aaa17cb25aa156b0c529745d5adb27db0 /Source/Core/Common/Hash.cpp | |
| parent | 85d2ea0dd28444effed13a622360253f2d74bcba (diff) | |
Common: Merge CRC32.h into Hash.h
This makes it easier to find the relevant functions.
Diffstat (limited to 'Source/Core/Common/Hash.cpp')
| -rw-r--r-- | Source/Core/Common/Hash.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp index d0b05ec7b6..692745cb0a 100644 --- a/Source/Core/Common/Hash.cpp +++ b/Source/Core/Common/Hash.cpp @@ -5,6 +5,8 @@ #include <algorithm> #include <cstring> +#include <zlib.h> + #include "Common/BitUtils.h" #include "Common/CPUDetect.h" #include "Common/CommonFuncs.h" @@ -529,4 +531,14 @@ void SetHash64Function() ptrHashFunction = &GetMurmurHash3; } } + +u32 ComputeCRC32(std::string_view data) +{ + const Bytef* buf = reinterpret_cast<const Bytef*>(data.data()); + uInt len = static_cast<uInt>(data.size()); + // Use zlib's crc32 implementation to compute the hash + u32 hash = crc32(0L, Z_NULL, 0); + hash = crc32(hash, buf, len); + return hash; +} } // namespace Common |
