Skip to content

Commit

Permalink
perf: move s_dml_holder to global
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Nov 5, 2024
1 parent 170766b commit ea9acec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/MaaUtils/Runtime/Runtime_Win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
MAA_NS_BEGIN

static std::filesystem::path s_library_dir_cache;
static std::unique_ptr<std::remove_pointer_t<HMODULE>, decltype(&FreeLibrary)> s_dml_holder(nullptr, &FreeLibrary);

const std::filesystem::path& library_dir()
{
Expand All @@ -23,7 +24,7 @@ void init_library_dir(HINSTANCE hinstDLL)

// fix https://github.com/MaaXYZ/MaaFramework/issues/394
const auto dml_path = s_library_dir_cache / "DirectML.dll";
static std::unique_ptr<std::remove_pointer_t<HMODULE>, BOOL (*)(HMODULE)> s_dml_holder(LoadLibraryW(dml_path.c_str()), &FreeLibrary);
s_dml_holder = decltype(s_dml_holder)(LoadLibraryW(dml_path.c_str()), &FreeLibrary);
}

MAA_NS_END
Expand Down

0 comments on commit ea9acec

Please sign in to comment.