Skip to content
Permalink
Browse files

Android/ButtonManager: Make most file-scope local variables non-alloc…

…ating

We can use std::array and const char* to make these capable of fully
being stored in the read-only segment, and get rid of a few static
constructors (144 of them).
  • Loading branch information...
lioncash committed Jun 8, 2019
1 parent 069497e commit 7842bd1179876f3bf595f91958e2b3148443d199
Showing with 6 additions and 5 deletions.
  1. +6 −5 Source/Android/jni/ButtonManager.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <array>
#include <sstream>
#include <string>
#include <unordered_map>
@@ -16,8 +17,8 @@ namespace ButtonManager
{
namespace
{
const std::string touchScreenKey = "Touchscreen";
const std::vector<std::string> configStrings = {
constexpr char touchScreenKey[] = "Touchscreen";
constexpr std::array<const char*, 143> configStrings{{
// GC
"InputA",
"InputB",
@@ -169,9 +170,9 @@ const std::vector<std::string> configStrings = {
"TurntableCrossRight",
// Rumble
"Rumble",
};
}};

const std::vector<ButtonType> configTypes = {
constexpr std::array<ButtonType, 143> configTypes{{
// GC
BUTTON_A,
BUTTON_B,
@@ -323,7 +324,7 @@ const std::vector<ButtonType> configTypes = {
TURNTABLE_CROSSFADE_RIGHT,
// Rumble
RUMBLE,
};
}};

std::unordered_map<std::string, InputDevice*> m_controllers;

0 comments on commit 7842bd1

Please sign in to comment.
You can’t perform that action at this time.