Permalink
Browse files

HotkeyManager: Convert file-scope std::string array to constexpr cons…

…t 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.
  • Loading branch information...
lioncash committed Jun 14, 2018
1 parent e8c1e5a commit d459470feef32756f2e6aed9d1670d6cf2d38341
Showing with 3 additions and 4 deletions.
  1. +3 −4 Source/Core/Core/HotkeyManager.cpp
@@ -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
{

0 comments on commit d459470

Please sign in to comment.