From ad998e8a80d18a9af9f063b7805bf179a7db0e74 Mon Sep 17 00:00:00 2001 From: Daniel Evans Date: Sun, 16 Oct 2016 20:37:07 +0100 Subject: [PATCH] Avoid allocating RWGame members where possible These objects don't need to be dynamically allocated, they can take on the same lifetime as RWGame itself. --- rwengine/src/data/GameTexts.hpp | 2 +- rwgame/RWGame.cpp | 121 ++++++++++++++------------------ rwgame/RWGame.hpp | 15 ++-- rwgame/states/DebugState.cpp | 2 +- rwgame/states/MenuState.cpp | 3 +- rwgame/states/PauseState.cpp | 5 +- 6 files changed, 66 insertions(+), 82 deletions(-) diff --git a/rwengine/src/data/GameTexts.hpp b/rwengine/src/data/GameTexts.hpp index 0c8baeab..6ef2ff9a 100644 --- a/rwengine/src/data/GameTexts.hpp +++ b/rwengine/src/data/GameTexts.hpp @@ -50,7 +50,7 @@ public: m_strings.emplace(id, text); } - GameString text(const GameStringKey& id) { + GameString text(const GameStringKey& id) const { auto a = m_strings.find(id); if (a != m_strings.end()) { return a->second; diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 1c94256d..4df030d3 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include