From 069497e87da5759a971c71584b23c005d98d97eb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 7 Jun 2019 20:02:00 -0400 Subject: [PATCH 1/3] Android/ButtonManager: Make local file-scope variables internally linked where applicable Silences a few -Wmissing-variable-declarations warnings. --- Source/Android/jni/ButtonManager.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Android/jni/ButtonManager.cpp b/Source/Android/jni/ButtonManager.cpp index fafc2ebe4d..554cc6f0e2 100644 --- a/Source/Android/jni/ButtonManager.cpp +++ b/Source/Android/jni/ButtonManager.cpp @@ -14,9 +14,10 @@ namespace ButtonManager { +namespace +{ const std::string touchScreenKey = "Touchscreen"; -std::unordered_map m_controllers; -std::vector configStrings = { +const std::vector configStrings = { // GC "InputA", "InputB", @@ -169,7 +170,8 @@ std::vector configStrings = { // Rumble "Rumble", }; -std::vector configTypes = { + +const std::vector configTypes = { // GC BUTTON_A, BUTTON_B, @@ -323,7 +325,9 @@ std::vector configTypes = { RUMBLE, }; -static void AddBind(const std::string& dev, sBind* bind) +std::unordered_map m_controllers; + +void AddBind(const std::string& dev, sBind* bind) { auto it = m_controllers.find(dev); if (it != m_controllers.end()) @@ -334,6 +338,7 @@ static void AddBind(const std::string& dev, sBind* bind) m_controllers[dev] = new InputDevice(dev); m_controllers[dev]->AddBind(bind); } +} // Anonymous namespace void Init(const std::string& gameId) { From 7842bd1179876f3bf595f91958e2b3148443d199 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 7 Jun 2019 20:12:34 -0400 Subject: [PATCH 2/3] 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; From eb15a52fd58613f4494acb6feae533156d3d6c7c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 7 Jun 2019 20:20:09 -0400 Subject: [PATCH 3/3] UICommon/ResourcePack/Manager: Make GetPackConfig() internally linked Silences a -Wmissing-declarations warning. --- Source/Core/UICommon/ResourcePack/Manager.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Core/UICommon/ResourcePack/Manager.cpp b/Source/Core/UICommon/ResourcePack/Manager.cpp index 0d2327e56e..1be409f6e6 100644 --- a/Source/Core/UICommon/ResourcePack/Manager.cpp +++ b/Source/Core/UICommon/ResourcePack/Manager.cpp @@ -11,15 +11,13 @@ #include -namespace -{ -std::vector packs; - -std::string packs_path; -} // namespace - namespace ResourcePack { +namespace +{ +std::vector packs; +std::string packs_path; + IniFile GetPackConfig() { packs_path = File::GetUserPath(D_RESOURCEPACK_IDX) + "/Packs.ini"; @@ -29,6 +27,7 @@ IniFile GetPackConfig() return file; } +} // Anonymous namespace bool Init() {