summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-03-20 19:52:11 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-03-20 19:52:11 +0000
commit2cdf5788347f3d837ada214d209f7d7bc92c8386 (patch)
tree19ae39a08f16178831f5ff67e1df02c9a1a43217 /src
parent0cdeb55968c4e313acb81ce7843334f89de1d6a2 (diff)
Store key names in a constexpr array
Diffstat (limited to 'src')
-rw-r--r--src/keys.cc8
1 files 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<String, Codepoint>;
-static std::vector<KeyAndName> keynamemap = {
+using KeyAndName = std::pair<const char*, Codepoint>;
+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;