From 391cf379ae7ddbf0b48c7f7059669533b2ed99bc Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 15 Jul 2014 21:42:32 -0500 Subject: [PATCH] Remove usages of HashTools::Dictionary/HashMap Replace these usages with unordered_map since they are just as quick --- pcsx2/gui/AppAccelerators.h | 14 +++++++------- pcsx2/gui/AppMain.cpp | 6 +++++- pcsx2/gui/FrameForGS.cpp | 7 +++++-- pcsx2/gui/GlobalCommands.cpp | 15 +++++---------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pcsx2/gui/AppAccelerators.h b/pcsx2/gui/AppAccelerators.h index 673fef7bc1..490791d394 100644 --- a/pcsx2/gui/AppAccelerators.h +++ b/pcsx2/gui/AppAccelerators.h @@ -16,7 +16,9 @@ #pragma once #include "AppCommon.h" -#include "Utilities/HashMap.h" + +#include +#include // -------------------------------------------------------------------------------------- // KeyAcceleratorCode @@ -105,31 +107,29 @@ struct GlobalCommandDescriptor // -------------------------------------------------------------------------------------- // CommandDictionary // -------------------------------------------------------------------------------------- -class CommandDictionary : public HashTools::Dictionary +class CommandDictionary : public std::unordered_map { - typedef HashTools::Dictionary _parent; + typedef std::unordered_map _parent; protected: public: using _parent::operator[]; - CommandDictionary(); virtual ~CommandDictionary() throw(); }; // -------------------------------------------------------------------------------------- // // -------------------------------------------------------------------------------------- -class AcceleratorDictionary : public HashTools::HashMap +class AcceleratorDictionary : public std::unordered_map { - typedef HashTools::HashMap _parent; + typedef std::unordered_map _parent; protected: public: using _parent::operator[]; - AcceleratorDictionary(); virtual ~AcceleratorDictionary() throw(); void Map( const KeyAcceleratorCode& acode, const char *searchfor ); }; diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index f860c0e275..a63d9293bf 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -565,7 +565,11 @@ void Pcsx2App::LogicalVsync() void Pcsx2App::OnEmuKeyDown( wxKeyEvent& evt ) { const GlobalCommandDescriptor* cmd = NULL; - if( GlobalAccels ) GlobalAccels->TryGetValue( KeyAcceleratorCode( evt ).val32, cmd ); + if (GlobalAccels) + { + if (GlobalAccels->find(KeyAcceleratorCode(evt).val32) != GlobalAccels->end()) + cmd = GlobalAccels->at(KeyAcceleratorCode(evt).val32); + } if( cmd == NULL ) { diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index f25afe883f..c9ff575ed8 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -293,8 +293,11 @@ void GSPanel::OnKeyDown( wxKeyEvent& evt ) void GSPanel::DirectKeyCommand( const KeyAcceleratorCode& kac ) { const GlobalCommandDescriptor* cmd = NULL; - m_Accels->TryGetValue( kac.val32, cmd ); - if( cmd == NULL ) return; + + if (m_Accels->find(kac.val32) == m_Accels->end()) + return; + + cmd = m_Accels->at(kac.val32); DbgCon.WriteLn( "(gsFrame) Invoking command: %s", cmd->Id ); cmd->Invoke(); diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index 2106928161..17da9f13d0 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -519,16 +519,8 @@ static const GlobalCommandDescriptor CommandDeclarations[] = { NULL } }; -CommandDictionary::CommandDictionary() {} - CommandDictionary::~CommandDictionary() throw() {} - -AcceleratorDictionary::AcceleratorDictionary() - : _parent( 0, 0xffffffff ) -{ -} - AcceleratorDictionary::~AcceleratorDictionary() throw() {} void AcceleratorDictionary::Map( const KeyAcceleratorCode& _acode, const char *searchfor ) @@ -552,7 +544,9 @@ void AcceleratorDictionary::Map( const KeyAcceleratorCode& _acode, const char *s // End of overrides section const GlobalCommandDescriptor* result = NULL; - TryGetValue( acode.val32, result ); + + if (find(acode.val32) != end()) + result = at(acode.val32); if( result != NULL ) { @@ -563,7 +557,8 @@ void AcceleratorDictionary::Map( const KeyAcceleratorCode& _acode, const char *s ); } - wxGetApp().GlobalCommands->TryGetValue( searchfor, result ); + if (wxGetApp().GlobalCommands->find(searchfor) != wxGetApp().GlobalCommands->end()) + result = wxGetApp().GlobalCommands->at(searchfor); if( result == NULL ) {