From d459470feef32756f2e6aed9d1670d6cf2d38341 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 14 Jun 2018 08:58:57 -0400 Subject: [PATCH] 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. --- Source/Core/Core/HotkeyManager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 67086b593c..7b3f04a5e6 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -20,7 +20,7 @@ #include "InputCommon/GCPadStatus.h" // clang-format off -const std::string hotkey_labels[] = { +constexpr std::array 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 {