mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
ue2_literal: better hash function
This commit is contained in:
parent
1aad3b0ed1
commit
25170b32eb
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "charreach.h"
|
#include "charreach.h"
|
||||||
#include "compare.h"
|
#include "compare.h"
|
||||||
|
#include "hash_dynamic_bitset.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -325,6 +326,10 @@ bool ue2_literal::any_nocase() const {
|
|||||||
return nocase.any();
|
return nocase.any();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ue2_literal::hash() const {
|
||||||
|
return hash_all(s, hash_dynamic_bitset()(nocase));
|
||||||
|
}
|
||||||
|
|
||||||
void make_nocase(ue2_literal *lit) {
|
void make_nocase(ue2_literal *lit) {
|
||||||
ue2_literal rv;
|
ue2_literal rv;
|
||||||
|
|
||||||
|
@ -205,6 +205,8 @@ public:
|
|||||||
nocase.swap(other.nocase);
|
nocase.swap(other.nocase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t hash() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend const_iterator;
|
friend const_iterator;
|
||||||
std::string s;
|
std::string s;
|
||||||
@ -321,7 +323,7 @@ struct hash<ue2::ue2_literal::elem> {
|
|||||||
template<>
|
template<>
|
||||||
struct hash<ue2::ue2_literal> {
|
struct hash<ue2::ue2_literal> {
|
||||||
size_t operator()(const ue2::ue2_literal &lit) const {
|
size_t operator()(const ue2::ue2_literal &lit) const {
|
||||||
return ue2::ue2_hasher()(lit);
|
return lit.hash();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user