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:
Bevan Weiss 2020-08-06 20:34:08 +10:00 committed by GitHub
parent eee5e812f7
commit ada6db2df4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 15 deletions

View file

@ -101,8 +101,6 @@ class ppu_module_manager final
{
friend class ppu_static_module;
static std::unordered_map<std::string, ppu_static_module*>& 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<std::string, ppu_static_module*>& 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<std::string, ppu_static_module*> s_module_map;
};
template <auto* Func>