mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: remove hasLiteral()
This commit is contained in:
parent
8a7ac432c0
commit
a75b2ba2e5
@ -484,7 +484,7 @@ bool checkFloatingKillableByPrefixes(const RoseBuildImpl &tbi) {
|
||||
}
|
||||
|
||||
static
|
||||
bool checkEodStealFloating(const RoseBuildImpl &tbi,
|
||||
bool checkEodStealFloating(const RoseBuildImpl &build,
|
||||
const vector<u32> &eodLiteralsForFloating,
|
||||
u32 numFloatingLiterals,
|
||||
size_t shortestFloatingLen) {
|
||||
@ -498,27 +498,36 @@ bool checkEodStealFloating(const RoseBuildImpl &tbi,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tbi.hasNoFloatingRoots()) {
|
||||
if (build.hasNoFloatingRoots()) {
|
||||
DEBUG_PRINTF("skipping as floating table is conditional\n");
|
||||
/* TODO: investigate putting stuff in atable */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkFloatingKillableByPrefixes(tbi)) {
|
||||
if (checkFloatingKillableByPrefixes(build)) {
|
||||
DEBUG_PRINTF("skipping as prefixes may make ftable conditional\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Collect a set of all floating literals.
|
||||
unordered_set<ue2_literal> floating_lits;
|
||||
for (auto &m : build.literals) {
|
||||
const auto &lit = m.left;
|
||||
if (lit.table == ROSE_FLOATING) {
|
||||
floating_lits.insert(lit.s);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("%zu are eod literals, %u floating; floating len=%zu\n",
|
||||
eodLiteralsForFloating.size(), numFloatingLiterals,
|
||||
shortestFloatingLen);
|
||||
u32 new_floating_lits = 0;
|
||||
|
||||
for (u32 eod_id : eodLiteralsForFloating) {
|
||||
const rose_literal_id &lit = tbi.literals.right.at(eod_id);
|
||||
const rose_literal_id &lit = build.literals.right.at(eod_id);
|
||||
DEBUG_PRINTF("checking '%s'\n", dumpString(lit.s).c_str());
|
||||
|
||||
if (tbi.hasLiteral(lit.s, ROSE_FLOATING)) {
|
||||
if (contains(floating_lits, lit.s)) {
|
||||
DEBUG_PRINTF("skip; there is already a floating version\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -490,8 +490,6 @@ public:
|
||||
const std::vector<u8> &cmp, u32 delay,
|
||||
rose_literal_table table);
|
||||
|
||||
bool hasLiteral(const ue2_literal &s, rose_literal_table table) const;
|
||||
|
||||
u32 getNewLiteralId(void);
|
||||
|
||||
void removeVertices(const std::vector<RoseVertex> &dead);
|
||||
|
@ -486,28 +486,6 @@ u32 RoseBuildImpl::getLiteralId(const ue2_literal &s, const vector<u8> &msk,
|
||||
return id;
|
||||
}
|
||||
|
||||
bool RoseBuildImpl::hasLiteral(const ue2_literal &s,
|
||||
rose_literal_table table) const {
|
||||
DEBUG_PRINTF("looking if %s exists\n", dumpString(s).c_str());
|
||||
assert(table != ROSE_ANCHORED);
|
||||
|
||||
for (RoseLiteralMap::left_map::const_iterator it
|
||||
= literals.left.lower_bound(rose_literal_id(s, table, 0));
|
||||
it != literals.left.end(); ++it) {
|
||||
if (it->first.table != table || it->first.s != s) {
|
||||
break;
|
||||
}
|
||||
const rose_literal_info &info = literal_info[it->second];
|
||||
if (!info.vertices.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("(used) literal not found\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 RoseBuildImpl::getNewLiteralId() {
|
||||
rose_literal_id key(ue2_literal(), ROSE_ANCHORED, 0);
|
||||
u32 numLiterals = verify_u32(literals.left.size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user