diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 1becdbbc5d..9d8f864fb0 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -61,21 +61,14 @@ ppu_static_module::ppu_static_module(const char* name) ppu_module_manager::register_module(this); } -std::unordered_map& ppu_module_manager::access() -{ - static std::unordered_map map; - - return map; -} - void ppu_module_manager::register_module(ppu_static_module* _module) { - access().emplace(_module->name, _module); + ppu_module_manager::s_module_map.emplace(_module->name, _module); } ppu_static_function& ppu_module_manager::access_static_function(const char* _module, u32 fnid) { - auto& res = access().at(_module)->functions[fnid]; + auto& res = ppu_module_manager::s_module_map.at(_module)->functions[fnid]; if (res.name) { @@ -87,7 +80,7 @@ ppu_static_function& ppu_module_manager::access_static_function(const char* _mod ppu_static_variable& ppu_module_manager::access_static_variable(const char* _module, u32 vnid) { - auto& res = access().at(_module)->variables[vnid]; + auto& res = ppu_module_manager::s_module_map.at(_module)->variables[vnid]; if (res.name) { @@ -99,7 +92,7 @@ ppu_static_variable& ppu_module_manager::access_static_variable(const char* _mod const ppu_static_module* ppu_module_manager::get_module(const std::string& name) { - const auto& map = access(); + const auto& map = ppu_module_manager::s_module_map; const auto found = map.find(name); return found != map.end() ? found->second : nullptr; } diff --git a/rpcs3/Emu/Cell/PPUModule.h b/rpcs3/Emu/Cell/PPUModule.h index 0bd9bf88af..105a2c592e 100644 --- a/rpcs3/Emu/Cell/PPUModule.h +++ b/rpcs3/Emu/Cell/PPUModule.h @@ -101,8 +101,6 @@ class ppu_module_manager final { friend class ppu_static_module; - static std::unordered_map& access(); - static void register_module(ppu_static_module*); static ppu_static_function& access_static_function(const char* _module, u32 fnid); @@ -161,9 +159,10 @@ public: return info; } - static const auto& get() + // We need this to deal with the enumeration over all ppu_static_modules that happens in ppu_initialize_modules + static const std::unordered_map& get() { - return access(); + return s_module_map; } static const ppu_static_module cellAdec; @@ -273,6 +272,9 @@ public: static const ppu_static_module sys_libc; static const ppu_static_module sys_lv2dbg; static const ppu_static_module static_hle; + +private: + inline static std::unordered_map s_module_map; }; template