Merge pull request #9011 from unknownbrackets/savestates

Use unordered lookups for better speed
This commit is contained in:
Henrik Rydgård 2016-09-25 16:08:51 +02:00 committed by GitHub
commit ff66fe7f89
2 changed files with 17 additions and 2 deletions

View file

@ -17,6 +17,7 @@
#include <algorithm>
#include <map>
#include <unordered_map>
#include "base/basictypes.h"
#include "base/logging.h"
@ -1251,7 +1252,7 @@ static const ReplacementTableEntry entries[] = {
static std::map<u32, u32> replacedInstructions;
static std::map<std::string, std::vector<int> > replacementNameLookup;
static std::unordered_map<std::string, std::vector<int> > replacementNameLookup;
void Replacement_Init() {
for (int i = 0; i < (int)ARRAY_SIZE(entries); i++) {

View file

@ -18,6 +18,7 @@
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include "base/mutex.h"
#include "ext/cityhash/city.h"
#include "Common/FileUtil.h"
@ -59,9 +60,22 @@ struct HashMapFunc {
bool operator < (const HashMapFunc &other) const {
return hash < other.hash || (hash == other.hash && size < other.size);
}
bool operator == (const HashMapFunc &other) const {
return hash == other.hash && size == other.size;
}
};
static std::set<HashMapFunc> hashMap;
namespace std {
template <>
struct hash<HashMapFunc> {
size_t operator()(const HashMapFunc &f) const {
return std::hash<u64>()(f.hash) ^ f.size;
}
};
}
static std::unordered_set<HashMapFunc> hashMap;
static std::string hashmapFileName;