From 252d71e55e752f0b991f4e94913cb459e6e3a4f6 Mon Sep 17 00:00:00 2001 From: Entryhazard <43305726+Entryhazard@users.noreply.github.com> Date: Sun, 22 Sep 2019 10:11:17 +0200 Subject: [PATCH] Retrieve the function pointer once (#1198) --- src/util/util_env.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index 7644e07fa..df0587b7e 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -36,13 +36,8 @@ namespace dxvk::env { void setThreadName(const std::string& name) { using SetThreadDescriptionProc = HRESULT (WINAPI *) (HANDLE, PCWSTR); - HMODULE module = ::GetModuleHandleW(L"kernel32.dll"); - - if (module == nullptr) - return; - - auto proc = reinterpret_cast( - ::GetProcAddress(module, "SetThreadDescription")); + static auto proc = reinterpret_cast( + ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), "SetThreadDescription")); if (proc != nullptr) { auto wideName = str::tows(name);