From f4f39e74fae3c8b8d8fdb2f560e8a50777b6de1d Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 20 May 2017 02:47:57 +0300 Subject: don't load the same PDB twice --- include/pdb/repo.hpp | 4 ++++ include/pdb/utils/file.hpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'include') diff --git a/include/pdb/repo.hpp b/include/pdb/repo.hpp index 239bd7e..aa5c3c3 100644 --- a/include/pdb/repo.hpp +++ b/include/pdb/repo.hpp @@ -9,10 +9,12 @@ #include "dbghelp.hpp" #include "module.hpp" #include "symbol.hpp" +#include "utils/file.hpp" #include #include #include +#include namespace pdb { @@ -45,5 +47,7 @@ namespace pdb std::map online_modules; std::map offline_modules; + + std::unordered_set module_ids; }; } diff --git a/include/pdb/utils/file.hpp b/include/pdb/utils/file.hpp index 5b83f2b..50975aa 100644 --- a/include/pdb/utils/file.hpp +++ b/include/pdb/utils/file.hpp @@ -5,14 +5,44 @@ #pragma once +#include + #include +#include +#include #include +#include namespace pdb { namespace file { std::size_t get_size(const std::string&); + + 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)); + } + }; + + ID query_id(const std::string&); } } + +namespace std +{ + template <> + struct hash + { + std::size_t operator()(const pdb::file::ID& id) const + { + return _Bitwise_hash{}(id.raw); + } + }; +} -- cgit v1.2.3