bool findPaths(const NGHolder &g, vector<Path> &paths) {
vector<NFAVertex> order = getTopoOrdering(g);
+ vector<size_t> read_count(num_vertices(g));
vector<vector<Path>> built(num_vertices(g));
for (auto it = order.rbegin(); it != order.rend(); ++it) {
auto &out = built[g[v].index];
assert(out.empty());
+ read_count[g[v].index] = out_degree(v, g);
+
+ DEBUG_PRINTF("setting read_count to %zu for %u\n",
+ read_count[g[v].index], g[v].index);
+
if (v == g.start || v == g.startDs) {
out.push_back({v});
continue;
continue;
}
+ assert(!built[g[u].index].empty());
+ assert(read_count[g[u].index]);
+
for (const auto &p : built[g[u].index]) {
out.push_back(p);
out.back().push_back(v);
return false;
}
}
+
+ read_count[g[u].index]--;
+ if (!read_count[g[u].index]) {
+ DEBUG_PRINTF("clearing %u as finished reading\n", g[u].index);
+ built[g[u].index].clear();
+ built[g[u].index].shrink_to_fit();
+ }
}
}
vector<NFAVertex> order = getTopoOrdering(g);
vector<set<sls_literal>> built(num_vertices(g));
+ vector<size_t> read_count(num_vertices(g));
for (auto it = order.rbegin(); it != order.rend(); ++it) {
NFAVertex v = *it;
set<sls_literal> &out = built[g[v].index];
+ read_count[g[v].index] = out_degree(v, g);
+
+ DEBUG_PRINTF("setting read_count to %zu for %u\n",
+ read_count[g[v].index], g[v].index);
assert(out.empty());
if (v == g.start) {
}
set<sls_literal> &in = built[g[u].index];
+ DEBUG_PRINTF("getting from %u (%zu reads to go)\n",
+ g[u].index, read_count[g[u].index]);
assert(!in.empty());
+ assert(read_count[g[u].index]);
for (const sls_literal &lit : in) {
if (accept) {
out.insert(lit.append((u8)c, nocase));
if (out.size() + literals->size() > MAX_LITERAL_SET_SIZE) {
+ DEBUG_PRINTF("too big %zu + %zu\n", out.size(),
+ literals->size());
return false;
}
}
}
+
+ read_count[g[u].index]--;
+ if (!read_count[g[u].index]) {
+ DEBUG_PRINTF("clearing %u as finished reading\n", g[u].index);
+ in.clear();
+ }
}
}
return false;
}
+ DEBUG_PRINTF("looking for literals\n");
+
map<sls_literal, ue2::flat_set<ReportID>> literals;
if (!findLiterals(g, &literals)) {
DEBUG_PRINTF(":(\n");