Replaced Plugin hasher with std specialisation.

This commit is contained in:
WrinklyNinja
2014-08-26 00:22:47 +01:00
parent c259553833
commit 805ccdf83e
5 changed files with 14 additions and 14 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ namespace loot {
in.close();
if (metadataList["plugins"])
plugins = metadataList["plugins"].as< unordered_set<Plugin, plugin_hash> >();
plugins = metadataList["plugins"].as< unordered_set<Plugin> >();
if (metadataList["globals"])
messages = metadataList["globals"].as< list<Message> >();
+1 -1
View File
@@ -61,7 +61,7 @@ namespace loot {
bool operator == (const MetadataList& rhs) const; //Compares content.
std::unordered_set<Plugin, plugin_hash> plugins;
std::unordered_set<Plugin> plugins;
std::list<Message> messages;
};
+1 -1
View File
@@ -431,7 +431,7 @@ namespace loot {
try {
this->MetadataList::Load(game.MasterlistPath());
unordered_set<Plugin, plugin_hash> tempSet;
unordered_set<Plugin> tempSet;
for (auto &plugin : plugins) {
tempSet.insert(Plugin(plugin).EvalAllConditions(game, language));
}
-6
View File
@@ -798,12 +798,6 @@ namespace loot {
return boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 3) + "bsa"));
}
size_t plugin_hash::operator () (const Plugin& p) const {
size_t seed = 0;
boost::hash_combine(seed, boost::locale::to_lower(p.Name()));
return seed;
}
bool operator == (const File& lhs, const Plugin& rhs) {
return boost::iequals(lhs.Name(), rhs.Name());
}
+11 -5
View File
@@ -32,6 +32,8 @@
#include <list>
#include <set>
#include <boost/locale.hpp>
namespace loot {
const unsigned int max_priority = 1000000;
@@ -243,11 +245,6 @@ namespace loot {
size_t numOverrideRecords;
};
struct plugin_hash : std::unary_function<Plugin, size_t> {
size_t operator () (const Plugin& p) const;
};
bool operator == (const File& lhs, const Plugin& rhs);
bool operator == (const Plugin& lhs, const File& rhs);
@@ -257,4 +254,13 @@ namespace loot {
bool IsPlugin(const std::string& file);
}
namespace std {
template<>
struct hash < loot::Plugin > {
size_t operator() (const loot::Plugin& plugin) {
return hash<string>()(boost::locale::to_lower(plugin.Name()));
}
};
}
#endif