From 2652aed85c0ab0ee9d51cfd5065b4bb4a620ab45 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 10 Dec 2021 12:47:03 -0800 Subject: Common: Merge CRC32.h into Hash.h This makes it easier to find the relevant functions. --- Source/Core/Common/Hash.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Source/Core/Common/Hash.cpp') 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 #include +#include + #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(data.data()); + uInt len = static_cast(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 -- cgit v1.2.3