summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-08 11:40:50 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-03-08 11:40:50 +0000
commit0bbaef6e48c7a22b59e2c70304f6ccbf17324412 (patch)
treea95dc56fac7cdc76383eb2ced803d58834f6b933 /src/input_handler.cc
parent3ece7bcf75d3cb7e2dad50497c11d1069f486c0e (diff)
Use a sorted array for keymap rather than an unordered map
with ~100 entry, a binary search finds in < 7 step, unordered map is overkill.
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 6edc61b5..2f67953b 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -127,13 +127,15 @@ public:
{
if (m_hooks_disabled)
do_restore_hooks = true;
- auto it = keymap.find(key);
- if (it != keymap.end())
+ auto it = std::lower_bound(keymap.begin(), keymap.end(), key,
+ [](const NormalCmdDesc& lhs, const Key& rhs)
+ { return lhs.key < rhs; });
+ if (it != keymap.end() and it->key == key)
{
if (context().options()["autoinfo"].get<int>() >= 2 and context().has_ui())
- context().ui().info_show(key_to_str(key), it->second.docstring, CharCoord{},
+ context().ui().info_show(key_to_str(key), it->docstring, CharCoord{},
get_face("Information"), InfoStyle::Prompt);
- it->second.func(context(), m_params);
+ it->func(context(), m_params);
}
m_params = { 0, '"' };
}