From 2652aed85c0ab0ee9d51cfd5065b4bb4a620ab45 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 10 Dec 2021 12:47:03 -0800 Subject: [PATCH] Common: Merge CRC32.h into Hash.h This makes it easier to find the relevant functions. --- Source/Core/Common/CMakeLists.txt | 2 -- Source/Core/Common/CRC32.cpp | 19 ------------------- Source/Core/Common/CRC32.h | 11 ----------- Source/Core/Common/Hash.cpp | 12 ++++++++++++ Source/Core/Common/Hash.h | 3 +++ Source/Core/Core/Boot/Boot.cpp | 2 +- Source/Core/DolphinLib.props | 2 -- 7 files changed, 16 insertions(+), 35 deletions(-) delete mode 100644 Source/Core/Common/CRC32.cpp delete mode 100644 Source/Core/Common/CRC32.h diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 669a629676..a2156c5b5d 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -25,8 +25,6 @@ add_library(common Config/Layer.cpp Config/Layer.h CPUDetect.h - CRC32.cpp - CRC32.h Crypto/AES.cpp Crypto/AES.h Crypto/bn.cpp diff --git a/Source/Core/Common/CRC32.cpp b/Source/Core/Common/CRC32.cpp deleted file mode 100644 index c09a578196..0000000000 --- a/Source/Core/Common/CRC32.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "Common/CRC32.h" - -#include - -namespace Common -{ -u32 ComputeCRC32(std::string_view data) -{ - const Bytef* buf = reinterpret_cast(data.data()); - uInt len = static_cast(data.size()); - // Use zlibs crc32 implementation to compute the hash - u32 hash = crc32(0L, Z_NULL, 0); - hash = crc32(hash, buf, len); - return hash; -} -} // namespace Common diff --git a/Source/Core/Common/CRC32.h b/Source/Core/Common/CRC32.h deleted file mode 100644 index 3f3f52b96a..0000000000 --- a/Source/Core/Common/CRC32.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2021 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include - -#include "Common/CommonTypes.h" - -namespace Common -{ -u32 ComputeCRC32(std::string_view data); -} // namespace Common 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 diff --git a/Source/Core/Common/Hash.h b/Source/Core/Common/Hash.h index 6e07a82f23..c346c343e4 100644 --- a/Source/Core/Common/Hash.h +++ b/Source/Core/Common/Hash.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "Common/CommonTypes.h" @@ -14,4 +15,6 @@ u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightl u32 HashEctor(const u8* ptr, size_t length); // JUNK. DO NOT USE FOR NEW THINGS u64 GetHash64(const u8* src, u32 len, u32 samples); void SetHash64Function(); + +u32 ComputeCRC32(std::string_view data); } // namespace Common diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 22f9b4f017..a08261b874 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -22,11 +22,11 @@ namespace fs = std::filesystem; #include "Common/Align.h" #include "Common/CDUtils.h" -#include "Common/CRC32.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/Config/Config.h" #include "Common/FileUtil.h" +#include "Common/Hash.h" #include "Common/IOFile.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 0940466a2a..6c267853df 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -21,7 +21,6 @@ - @@ -687,7 +686,6 @@ -