From 5b4d2736a825c314047fb4eb4286ff5690dcba6e Mon Sep 17 00:00:00 2001 From: j v Date: Fri, 17 Jun 2022 21:06:20 -0700 Subject: [PATCH] Custom hash algorithm for CLSID --- src/PreviewWindow.cpp | 9 +++++++-- src/main.cpp | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PreviewWindow.cpp b/src/PreviewWindow.cpp index 8a80e7b..1c259f4 100644 --- a/src/PreviewWindow.cpp +++ b/src/PreviewWindow.cpp @@ -8,8 +8,13 @@ template<> struct std::hash { std::size_t operator() (const CLSID &key) const { - RPC_STATUS status; - return std::hash()(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()(dword); + } + return hash; } }; diff --git a/src/main.cpp b/src/main.cpp index 84df433..da5a406 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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";