ue2_literal: better hash function

This commit is contained in:
Justin Viiret 2017-08-10 15:12:28 +10:00 committed by Matthew Barr
parent 1aad3b0ed1
commit 25170b32eb
2 changed files with 8 additions and 1 deletions

View File

@ -34,6 +34,7 @@
#include "charreach.h"
#include "compare.h"
#include "hash_dynamic_bitset.h"
#include <algorithm>
#include <cstring>
@ -325,6 +326,10 @@ bool ue2_literal::any_nocase() const {
return nocase.any();
}
size_t ue2_literal::hash() const {
return hash_all(s, hash_dynamic_bitset()(nocase));
}
void make_nocase(ue2_literal *lit) {
ue2_literal rv;

View File

@ -205,6 +205,8 @@ public:
nocase.swap(other.nocase);
}
size_t hash() const;
private:
friend const_iterator;
std::string s;
@ -321,7 +323,7 @@ struct hash<ue2::ue2_literal::elem> {
template<>
struct hash<ue2::ue2_literal> {
size_t operator()(const ue2::ue2_literal &lit) const {
return ue2::ue2_hasher()(lit);
return lit.hash();
}
};