mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
TeddySet: doesn't need a reference to lits
This commit is contained in:
parent
d626cb68e0
commit
bae7a072ca
@ -79,7 +79,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class TeddySet {
|
class TeddySet {
|
||||||
const vector<hwlmLiteral> &lits;
|
|
||||||
u32 len;
|
u32 len;
|
||||||
// nibbleSets is a series of bitfields over 16 predicates
|
// nibbleSets is a series of bitfields over 16 predicates
|
||||||
// that represent the whether shufti nibble set
|
// that represent the whether shufti nibble set
|
||||||
@ -89,8 +88,7 @@ class TeddySet {
|
|||||||
vector<u16> nibbleSets;
|
vector<u16> nibbleSets;
|
||||||
set<u32> litIds;
|
set<u32> litIds;
|
||||||
public:
|
public:
|
||||||
TeddySet(const vector<hwlmLiteral> &lits_in, u32 len_in)
|
explicit TeddySet(u32 len_in) : len(len_in), nibbleSets(len_in * 2, 0) {}
|
||||||
: lits(lits_in), len(len_in), nibbleSets(len_in * 2, 0) {}
|
|
||||||
const set<u32> & getLits() const { return litIds; }
|
const set<u32> & getLits() const { return litIds; }
|
||||||
size_t litCount() const { return litIds.size(); }
|
size_t litCount() const { return litIds.size(); }
|
||||||
|
|
||||||
@ -118,15 +116,15 @@ public:
|
|||||||
return nibbleSets == ts.nibbleSets;
|
return nibbleSets == ts.nibbleSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLiteral(u32 lit_id) {
|
void addLiteral(u32 lit_id, const hwlmLiteral &lit) {
|
||||||
const string &s = lits[lit_id].s;
|
const string &s = lit.s;
|
||||||
for (u32 i = 0; i < len; i++) {
|
for (u32 i = 0; i < len; i++) {
|
||||||
if (i < s.size()) {
|
if (i < s.size()) {
|
||||||
u8 c = s[s.size() - i - 1];
|
u8 c = s[s.size() - i - 1];
|
||||||
u8 c_hi = (c >> 4) & 0xf;
|
u8 c_hi = (c >> 4) & 0xf;
|
||||||
u8 c_lo = c & 0xf;
|
u8 c_lo = c & 0xf;
|
||||||
nibbleSets[i*2] = 1 << c_lo;
|
nibbleSets[i*2] = 1 << c_lo;
|
||||||
if (lits[lit_id].nocase && ourisalpha(c)) {
|
if (lit.nocase && ourisalpha(c)) {
|
||||||
nibbleSets[i*2+1] = (1 << (c_hi&0xd)) | (1 << (c_hi|0x2));
|
nibbleSets[i*2+1] = (1 << (c_hi&0xd)) | (1 << (c_hi|0x2));
|
||||||
} else {
|
} else {
|
||||||
nibbleSets[i*2+1] = 1 << c_hi;
|
nibbleSets[i*2+1] = 1 << c_hi;
|
||||||
@ -185,8 +183,8 @@ bool TeddyCompiler::pack(map<BucketIndex,
|
|||||||
set<TeddySet> sts;
|
set<TeddySet> sts;
|
||||||
|
|
||||||
for (u32 i = 0; i < lits.size(); i++) {
|
for (u32 i = 0; i < lits.size(); i++) {
|
||||||
TeddySet ts(lits, eng.numMasks);
|
TeddySet ts(eng.numMasks);
|
||||||
ts.addLiteral(i);
|
ts.addLiteral(i, lits[i]);
|
||||||
sts.insert(ts);
|
sts.insert(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +212,7 @@ bool TeddyCompiler::pack(map<BucketIndex,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeddySet tmpSet(lits, eng.numMasks);
|
TeddySet tmpSet(eng.numMasks);
|
||||||
tmpSet.merge(s1);
|
tmpSet.merge(s1);
|
||||||
tmpSet.merge(s2);
|
tmpSet.merge(s2);
|
||||||
u64a newScore = tmpSet.heuristic();
|
u64a newScore = tmpSet.heuristic();
|
||||||
@ -244,7 +242,7 @@ bool TeddyCompiler::pack(map<BucketIndex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do the merge
|
// do the merge
|
||||||
TeddySet nts(lits, eng.numMasks);
|
TeddySet nts(eng.numMasks);
|
||||||
nts.merge(*m1);
|
nts.merge(*m1);
|
||||||
nts.merge(*m2);
|
nts.merge(*m2);
|
||||||
#ifdef TEDDY_DEBUG
|
#ifdef TEDDY_DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user