From 70d67b6e5e73608f7f851056f497121120e318c2 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 28 Dec 2005 20:50:12 +0000 Subject: [PATCH] fix slightly excessive memory usage --- stepmania/src/InputMapper.cpp | 27 +++++++++++++-------------- stepmania/src/InputMapper.h | 3 --- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 07377a4a6b..d6c82d0a57 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -16,6 +16,13 @@ static Preference g_sLastSeenInputDevices( "LastSeenInputDevices", "" ); static Preference g_bAutoMapOnJoyChange( "AutoMapOnJoyChange", true ); +namespace +{ + // lookup for efficiency from a DeviceInput to a GameInput + // This is repopulated every time m_PItoDI changes by calling UpdateTempDItoPI(). + map g_tempDItoGI; +}; + InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program InputMapper::InputMapper() @@ -27,6 +34,7 @@ InputMapper::InputMapper() InputMapper::~InputMapper() { SaveMappingsToDisk(); + g_tempDItoGI.clear(); } void InputMapper::ClearAllMappings() @@ -607,7 +615,7 @@ bool InputMapper::ClearFromInputMap( const GameInput &GameI, int iSlotIndex ) bool InputMapper::IsMapped( const DeviceInput &DeviceI ) { - return m_tempDItoGI[DeviceI.device][DeviceI.button].IsValid(); + return g_tempDItoGI.find(DeviceI) != g_tempDItoGI.end(); } bool InputMapper::IsMapped( const GameInput &GameI ) @@ -622,17 +630,8 @@ bool InputMapper::IsMapped( const GameInput &GameI ) void InputMapper::UpdateTempDItoGI() { - // clear out m_tempDItoGI - FOREACH_InputDevice( d ) - { - for( int b=0; b