From 7842bd1179876f3bf595f91958e2b3148443d199 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 7 Jun 2019 20:12:34 -0400 Subject: [PATCH] Android/ButtonManager: Make most file-scope local variables non-allocating 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). --- Source/Android/jni/ButtonManager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Android/jni/ButtonManager.cpp b/Source/Android/jni/ButtonManager.cpp index 554cc6f0e2..7530e37cfd 100644 --- a/Source/Android/jni/ButtonManager.cpp +++ b/Source/Android/jni/ButtonManager.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include #include @@ -16,8 +17,8 @@ namespace ButtonManager { namespace { -const std::string touchScreenKey = "Touchscreen"; -const std::vector configStrings = { +constexpr char touchScreenKey[] = "Touchscreen"; +constexpr std::array configStrings{{ // GC "InputA", "InputB", @@ -169,9 +170,9 @@ const std::vector configStrings = { "TurntableCrossRight", // Rumble "Rumble", -}; +}}; -const std::vector configTypes = { +constexpr std::array configTypes{{ // GC BUTTON_A, BUTTON_B, @@ -323,7 +324,7 @@ const std::vector configTypes = { TURNTABLE_CROSSFADE_RIGHT, // Rumble RUMBLE, -}; +}}; std::unordered_map m_controllers;