mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
Replace ppu_module_manager Function Static with Class Static variable (static module map) (#8669)
* Replace ppu_module_manager Function Static with Class Static Makes for a slightly 'cleaner' interface in my opinion, may also assist with adding thread read/write concurrency support in future if ever required (have left that out of this commit to match existing function). Very slight performance improvements were seen in representative testing. https://quick-bench.com/q/GMbgeNc-mZc21aqOKCofnbzPZvg I didn't investigate whether static initialisation of the static_modules might actually be possible here, perhaps there's a way to do a constexpr / consteval of this. * Fix up for old style cast syntax.. * Fixups from PR comments Plus remove spurious type_traits include (from me) not picked up in previous PR * Remove old code * Update rpcs3/Emu/Cell/PPUModule.h Co-authored-by: Eladash <elad3356p@gmail.com> * Fix naming of static variable Co-authored-by: Eladash <elad3356p@gmail.com>
This commit is contained in:
parent
eee5e812f7
commit
ada6db2df4
2 changed files with 10 additions and 15 deletions
|
|
@ -61,21 +61,14 @@ ppu_static_module::ppu_static_module(const char* name)
|
|||
ppu_module_manager::register_module(this);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, ppu_static_module*>& ppu_module_manager::access()
|
||||
{
|
||||
static std::unordered_map<std::string, ppu_static_module*> 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue