mirror of https://github.com/PCSX2/pcsx2.git
pcsx2: Simplify GameDB hashing
Converting the string to lowercase is unnecessary when the actual entry is still case sensitive. Also just use std::hash of std::string and std::wstring instead, which fixes a FreeBSD compile error (cannot convert to const char*).
This commit is contained in:
parent
bde62436fa
commit
6e3d6a1b17
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
//#include "Common.h"
|
//#include "Common.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include "Utilities/HashMap.h"
|
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
|
@ -25,14 +24,15 @@
|
||||||
struct key_pair;
|
struct key_pair;
|
||||||
struct Game_Data;
|
struct Game_Data;
|
||||||
|
|
||||||
class StringHashNoCase
|
struct StringHash
|
||||||
{
|
{
|
||||||
public:
|
std::size_t operator()( const wxString& src ) const
|
||||||
StringHashNoCase() {}
|
|
||||||
|
|
||||||
HashTools::hash_key_t operator()( const wxString& src ) const
|
|
||||||
{
|
{
|
||||||
return HashTools::Hash( (const char *)src.Lower().wc_str(), src.length() * sizeof( wxChar ) );
|
#ifdef _WIN32
|
||||||
|
return std::hash<std::wstring>{}(src.ToStdWstring());
|
||||||
|
#else
|
||||||
|
return std::hash<std::string>{}({src.utf8_str()});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,13 +131,11 @@ public:
|
||||||
virtual Game_Data* createNewGame( const wxString& id )=0;
|
virtual Game_Data* createNewGame( const wxString& id )=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unordered_map<wxString, Game_Data*, StringHashNoCase> GameDataHash;
|
typedef std::unordered_map<wxString, Game_Data*, StringHash> GameDataHash;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// BaseGameDatabaseImpl
|
// BaseGameDatabaseImpl
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// [TODO] Create a version of this that uses google hashsets; should be several magnitudes
|
|
||||||
// faster that way.
|
|
||||||
class BaseGameDatabaseImpl : public IGameDatabase
|
class BaseGameDatabaseImpl : public IGameDatabase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue