HotkeyManager: Convert file-scope std::string array to constexpr const char* array

Previously, a total of 114 std::string instances would need to construct
(allocating on the heap for larger strings that can't be stored with
small string optimizations). We can just use an array of const char*
strings instead, which allows us to avoid this.
This commit is contained in:
Lioncash 2018-06-14 08:58:57 -04:00
parent e8c1e5af63
commit d459470fee
1 changed files with 3 additions and 4 deletions

View File

@ -20,7 +20,7 @@
#include "InputCommon/GCPadStatus.h"
// clang-format off
const std::string hotkey_labels[] = {
constexpr std::array<const char*, 114> hotkey_labels{{
_trans("Open"),
_trans("Change Disc"),
_trans("Eject Disc"),
@ -154,10 +154,9 @@ const std::string hotkey_labels[] = {
_trans("Undo Save State"),
_trans("Save State"),
_trans("Load State"),
};
}};
// clang-format on
static_assert(NUM_HOTKEYS == sizeof(hotkey_labels) / sizeof(hotkey_labels[0]),
"Wrong count of hotkey_labels");
static_assert(NUM_HOTKEYS == hotkey_labels.size(), "Wrong count of hotkey_labels");
namespace HotkeyManagerEmu
{