From 0bbaef6e48c7a22b59e2c70304f6ccbf17324412 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 8 Mar 2015 11:40:50 +0000 Subject: 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. --- src/input_handler.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/input_handler.cc') 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() >= 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, '"' }; } -- cgit v1.2.3