Skip to content

Commit

Permalink
Custom hash algorithm for CLSID
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jun 18, 2022
1 parent d066bbc commit 5b4d273
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/PreviewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
template<>
struct std::hash<CLSID> {
std::size_t operator() (const CLSID &key) const {
RPC_STATUS status;
return std::hash<unsigned short>()(UuidHash((UUID *)&key, &status));
// https://stackoverflow.com/a/263416
size_t hash = 17;
for (int i = 0; i < 4; i++) {
uint32_t dword = ((uint32_t *)&key)[i];
hash = hash * 23 + std::hash<uint32_t>()(dword);
}
return hash;
}
};

Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#pragma comment(lib, "Gdi32.lib")
#pragma comment(lib, "UxTheme.lib")
#pragma comment(lib, "Comctl32.lib")
#pragma comment(lib, "Rpcrt4.lib")

const wchar_t *APP_ID = L"chroma.browse";

Expand Down

0 comments on commit 5b4d273

Please sign in to comment.