crypto: Make KeyManager a singleton class
Previously, we were reading the keys everytime a KeyManager object was created, causing yuzu to reread the keys file multiple hundreds of times when loading the game list. With this change, it is only loaded once. On my system, this decreased game list loading times by a factor of 20.
This commit is contained in:
parent
41682e0888
commit
9f82a9a244
13 changed files with 27 additions and 21 deletions
|
@ -223,7 +223,13 @@ bool operator<(const KeyIndex<KeyType>& lhs, const KeyIndex<KeyType>& rhs) {
|
|||
|
||||
class KeyManager {
|
||||
public:
|
||||
KeyManager();
|
||||
static KeyManager& instance() {
|
||||
static KeyManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
KeyManager(KeyManager const&) = delete;
|
||||
void operator=(KeyManager const&) = delete;
|
||||
|
||||
bool HasKey(S128KeyType id, u64 field1 = 0, u64 field2 = 0) const;
|
||||
bool HasKey(S256KeyType id, u64 field1 = 0, u64 field2 = 0) const;
|
||||
|
@ -257,6 +263,8 @@ public:
|
|||
bool AddTicketPersonalized(Ticket raw);
|
||||
|
||||
private:
|
||||
KeyManager();
|
||||
|
||||
std::map<KeyIndex<S128KeyType>, Key128> s128_keys;
|
||||
std::map<KeyIndex<S256KeyType>, Key256> s256_keys;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue