mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
insertion_ordered_{map,set}: add new containers
These are associative map/set structures that are iterable in insertion order.
This commit is contained in:
committed by
Matthew Barr
parent
72973ccb47
commit
3ff70d5568
@@ -55,6 +55,7 @@
|
||||
#include "util/container.h"
|
||||
#include "util/dump_charclass.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/insertion_ordered.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/noncopyable.h"
|
||||
#include "util/order_check.h"
|
||||
@@ -1525,8 +1526,7 @@ bool RoseBuildImpl::addRose(const RoseInGraph &ig, bool prefilter) {
|
||||
renumber_vertices(in);
|
||||
assert(validateKinds(in));
|
||||
|
||||
map<NGHolder *, vector<RoseInEdge> > graphs;
|
||||
vector<NGHolder *> ordered_graphs; // Stored in first-encounter order.
|
||||
insertion_ordered_map<NGHolder *, vector<RoseInEdge>> graphs;
|
||||
|
||||
for (const auto &e : edges_range(in)) {
|
||||
if (!in[e].graph) {
|
||||
@@ -1544,21 +1544,17 @@ bool RoseBuildImpl::addRose(const RoseInGraph &ig, bool prefilter) {
|
||||
NGHolder *h = in[e].graph.get();
|
||||
|
||||
assert(isCorrectlyTopped(*h));
|
||||
if (!contains(graphs, h)) {
|
||||
ordered_graphs.push_back(h);
|
||||
}
|
||||
graphs[h].push_back(e);
|
||||
}
|
||||
|
||||
assert(ordered_graphs.size() == graphs.size());
|
||||
|
||||
vector<RoseInEdge> graph_edges;
|
||||
|
||||
for (auto h : ordered_graphs) {
|
||||
for (const auto &m : graphs) {
|
||||
NGHolder *h = m.first;
|
||||
if (!canImplementGraph(*h, prefilter, rm, cc)) {
|
||||
return false;
|
||||
}
|
||||
insert(&graph_edges, graph_edges.end(), graphs[h]);
|
||||
insert(&graph_edges, graph_edges.end(), m.second);
|
||||
}
|
||||
|
||||
/* we are now past the point of no return. We can start making irreversible
|
||||
|
@@ -86,6 +86,7 @@
|
||||
#include "util/container.h"
|
||||
#include "util/fatbit_build.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/insertion_ordered.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/multibit_build.h"
|
||||
#include "util/noncopyable.h"
|
||||
@@ -1474,11 +1475,11 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||
RoseGraph &g = tbi.g;
|
||||
const CompileContext &cc = tbi.cc;
|
||||
|
||||
map<left_id, set<PredTopPair> > infixTriggers;
|
||||
vector<left_id> order;
|
||||
unordered_map<left_id, vector<RoseVertex>> succs;
|
||||
map<left_id, set<PredTopPair>> infixTriggers;
|
||||
findInfixTriggers(tbi, &infixTriggers);
|
||||
|
||||
insertion_ordered_map<left_id, vector<RoseVertex>> succs;
|
||||
|
||||
if (cc.grey.allowTamarama && cc.streaming && !do_prefix) {
|
||||
findExclusiveInfixes(tbi, bc, qif, infixTriggers, no_retrigger_queues);
|
||||
}
|
||||
@@ -1517,10 +1518,6 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||
}
|
||||
}
|
||||
|
||||
if (!contains(succs, leftfix)) {
|
||||
order.push_back(leftfix);
|
||||
}
|
||||
|
||||
succs[leftfix].push_back(v);
|
||||
}
|
||||
|
||||
@@ -1529,8 +1526,9 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||
|
||||
map<left_id, eager_info> eager;
|
||||
|
||||
for (const left_id &leftfix : order) {
|
||||
const auto &left_succs = succs[leftfix];
|
||||
for (const auto &m : succs) {
|
||||
const left_id &leftfix = m.first;
|
||||
const auto &left_succs = m.second;
|
||||
|
||||
rose_group squash_mask = tbi.rose_squash_masks.at(leftfix);
|
||||
eager_info ei;
|
||||
@@ -1549,9 +1547,11 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||
eager.clear();
|
||||
}
|
||||
|
||||
for (const left_id &leftfix : order) {
|
||||
for (const auto &m : succs) {
|
||||
const left_id &leftfix = m.first;
|
||||
const auto &left_succs = m.second;
|
||||
buildLeftfix(tbi, bc, do_prefix, qif.get_queue(), infixTriggers,
|
||||
no_retrigger_queues, eager_queues, eager, succs[leftfix],
|
||||
no_retrigger_queues, eager_queues, eager, left_succs,
|
||||
leftfix);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user