From 2cdf5788347f3d837ada214d209f7d7bc92c8386 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 20 Mar 2014 19:52:11 +0000 Subject: [PATCH] Store key names in a constexpr array --- src/keys.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/keys.cc b/src/keys.cc index 17789ccd..cecf9634 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -16,8 +16,8 @@ Key canonicalize_ifn(Key key) return key; } -using KeyAndName = std::pair; -static std::vector keynamemap = { +using KeyAndName = std::pair; +static constexpr KeyAndName keynamemap[] = { { "ret", '\r' }, { "space", ' ' }, { "tab", '\t' }, @@ -73,7 +73,7 @@ KeyList parse_keys(const String& str) } auto it = find_if(keynamemap, [&keyname](const KeyAndName& item) { return item.first == keyname; }); - if (it != keynamemap.end()) + if (it != end(keynamemap)) { Key key = canonicalize_ifn(Key{ modifier, it->second }); result.push_back(key); @@ -116,7 +116,7 @@ String key_to_str(Key key) String res; auto it = find_if(keynamemap, [&key](const KeyAndName& item) { return item.second == key.key; }); - if (it != keynamemap.end()) + if (it != end(keynamemap)) { named = true; res = it->first;