keycode.cpp: use std::unordered_map for keypress cache

This commit is contained in:
Loic Blot 2017-09-21 18:47:42 +02:00
parent 69f3c424c1
commit 080899b0f1
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987

@ -359,13 +359,13 @@ const KeyPress CancelKey("KEY_CANCEL");
*/ */
// A simple cache for quicker lookup // A simple cache for quicker lookup
std::map<std::string, KeyPress> g_key_setting_cache; std::unordered_map<std::string, KeyPress> g_key_setting_cache;
KeyPress getKeySetting(const char *settingname) KeyPress getKeySetting(const char *settingname)
{ {
std::map<std::string, KeyPress>::iterator n; std::unordered_map<std::string, KeyPress>::iterator n;
n = g_key_setting_cache.find(settingname); n = g_key_setting_cache.find(settingname);
if(n != g_key_setting_cache.end()) if (n != g_key_setting_cache.end())
return n->second; return n->second;
KeyPress k(g_settings->get(settingname).c_str()); KeyPress k(g_settings->get(settingname).c_str());