Remove usages of HashTools::Dictionary/HashMap

Replace these usages with unordered_map since they are just as quick
This commit is contained in:
Ryan Houdek 2014-07-15 21:42:32 -05:00
parent 264cce2003
commit 391cf379ae
4 changed files with 22 additions and 20 deletions

View File

@ -16,7 +16,9 @@
#pragma once
#include "AppCommon.h"
#include "Utilities/HashMap.h"
#include <string>
#include <unordered_map>
// --------------------------------------------------------------------------------------
// KeyAcceleratorCode
@ -105,31 +107,29 @@ struct GlobalCommandDescriptor
// --------------------------------------------------------------------------------------
// CommandDictionary
// --------------------------------------------------------------------------------------
class CommandDictionary : public HashTools::Dictionary<const GlobalCommandDescriptor*>
class CommandDictionary : public std::unordered_map<std::string, const GlobalCommandDescriptor*>
{
typedef HashTools::Dictionary<const GlobalCommandDescriptor*> _parent;
typedef std::unordered_map<std::string, const GlobalCommandDescriptor*> _parent;
protected:
public:
using _parent::operator[];
CommandDictionary();
virtual ~CommandDictionary() throw();
};
// --------------------------------------------------------------------------------------
//
// --------------------------------------------------------------------------------------
class AcceleratorDictionary : public HashTools::HashMap<int, const GlobalCommandDescriptor*>
class AcceleratorDictionary : public std::unordered_map<int, const GlobalCommandDescriptor*>
{
typedef HashTools::HashMap<int, const GlobalCommandDescriptor*> _parent;
typedef std::unordered_map<int, const GlobalCommandDescriptor*> _parent;
protected:
public:
using _parent::operator[];
AcceleratorDictionary();
virtual ~AcceleratorDictionary() throw();
void Map( const KeyAcceleratorCode& acode, const char *searchfor );
};

View File

@ -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 )
{

View File

@ -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();

View File

@ -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 )
{