From 9f82a9a2444a232e746992fa89084b928255cb63 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Wed, 20 May 2020 21:28:16 +0200 Subject: 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. --- src/core/crypto/key_manager.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/core/crypto') diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 7265c4171..bf3434e1c 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -223,7 +223,13 @@ bool operator<(const KeyIndex& lhs, const KeyIndex& 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, Key128> s128_keys; std::map, Key256> s256_keys; -- cgit v1.2.3