From 0fe0e7ff60a87834a4838e4f1ec651cf7c78a2f2 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 6 Aug 2017 23:54:52 +0300 Subject: don't hash bitwise (because you know, padding) --- include/pdb/utils/file.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/pdb/utils/file.hpp b/include/pdb/utils/file.hpp index 50975aa..bf97115 100644 --- a/include/pdb/utils/file.hpp +++ b/include/pdb/utils/file.hpp @@ -7,12 +7,15 @@ #include +#pragma warning(push, 0) +#include +#pragma warning(pop) + #include #include #include #include -#include namespace pdb { @@ -20,14 +23,19 @@ namespace pdb { std::size_t get_size(const std::string&); + inline bool operator==(const FILE_ID_128& a, const FILE_ID_128& b) + { + return 0 == std::memcmp(a.Identifier, b.Identifier, sizeof(a.Identifier)); + } + struct ID { const FILE_ID_INFO raw; bool operator==(const ID& other) const { - static_assert(std::is_pod::value, "Can't memcmp if file IDs aren't PODs"); - return 0 == std::memcmp(&raw, &other.raw, sizeof(FILE_ID_INFO)); + return raw.VolumeSerialNumber == other.raw.VolumeSerialNumber + && raw.FileId == other.raw.FileId; } }; @@ -42,7 +50,10 @@ namespace std { std::size_t operator()(const pdb::file::ID& id) const { - return _Bitwise_hash{}(id.raw); + std::size_t seed = 0; + boost::hash_combine(seed, id.raw.VolumeSerialNumber); + boost::hash_combine(seed, id.raw.FileId.Identifier); + return seed; } }; } -- cgit v1.2.3