summaryrefslogtreecommitdiff
path: root/src/core/crypto
diff options
context:
space:
mode:
authorGravatar FearlessTobi2020-05-20 21:28:16 +0200
committerGravatar FearlessTobi2020-05-20 21:28:16 +0200
commit9f82a9a2444a232e746992fa89084b928255cb63 (patch)
tree2d26c90e5bb2edf975afe511f9999beca8c48382 /src/core/crypto
parentMerge pull request #3815 from FernandoS27/command-list-2 (diff)
downloadyuzu-9f82a9a2444a232e746992fa89084b928255cb63.tar.gz
yuzu-9f82a9a2444a232e746992fa89084b928255cb63.tar.xz
yuzu-9f82a9a2444a232e746992fa89084b928255cb63.zip
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.
Diffstat (limited to 'src/core/crypto')
-rw-r--r--src/core/crypto/key_manager.h10
1 files changed, 9 insertions, 1 deletions
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<KeyType>& lhs, const KeyIndex<KeyType>& rhs) {
223 223
224class KeyManager { 224class KeyManager {
225public: 225public:
226 KeyManager(); 226 static KeyManager& instance() {
227 static KeyManager instance;
228 return instance;
229 }
230
231 KeyManager(KeyManager const&) = delete;
232 void operator=(KeyManager const&) = delete;
227 233
228 bool HasKey(S128KeyType id, u64 field1 = 0, u64 field2 = 0) const; 234 bool HasKey(S128KeyType id, u64 field1 = 0, u64 field2 = 0) const;
229 bool HasKey(S256KeyType id, u64 field1 = 0, u64 field2 = 0) const; 235 bool HasKey(S256KeyType id, u64 field1 = 0, u64 field2 = 0) const;
@@ -257,6 +263,8 @@ public:
257 bool AddTicketPersonalized(Ticket raw); 263 bool AddTicketPersonalized(Ticket raw);
258 264
259private: 265private:
266 KeyManager();
267
260 std::map<KeyIndex<S128KeyType>, Key128> s128_keys; 268 std::map<KeyIndex<S128KeyType>, Key128> s128_keys;
261 std::map<KeyIndex<S256KeyType>, Key256> s256_keys; 269 std::map<KeyIndex<S256KeyType>, Key256> s256_keys;
262 270