mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
ng_region: use small_color_map
This commit is contained in:
parent
1392be048a
commit
8982e7177c
@ -58,6 +58,7 @@
|
|||||||
#include "util/container.h"
|
#include "util/container.h"
|
||||||
#include "util/ue2_containers.h"
|
#include "util/ue2_containers.h"
|
||||||
#include "util/graph_range.h"
|
#include "util/graph_range.h"
|
||||||
|
#include "util/graph_small_color_map.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -407,19 +408,20 @@ void liftSinks(const AcyclicGraph &acyclic_g, vector<NFAVertex> &topoOrder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using ColorMap = decltype(make_small_color_map(NGHolder()));
|
||||||
|
|
||||||
/** Build a reverse topo ordering (with only the specials that are in use). We
|
/** Build a reverse topo ordering (with only the specials that are in use). We
|
||||||
* also want to ensure vertices which only lead to back edges are placed near
|
* also want to ensure vertices which only lead to back edges are placed near
|
||||||
* their parents. */
|
* their parents. */
|
||||||
static
|
static
|
||||||
vector<NFAVertex> buildTopoOrder(const NGHolder &w,
|
vector<NFAVertex> buildTopoOrder(const NGHolder &w,
|
||||||
const AcyclicGraph &acyclic_g,
|
const AcyclicGraph &acyclic_g,
|
||||||
vector<boost::default_color_type> &colours) {
|
ColorMap &colours) {
|
||||||
vector<NFAVertex> topoOrder;
|
vector<NFAVertex> topoOrder;
|
||||||
topoOrder.reserve(num_vertices(w));
|
topoOrder.reserve(num_vertices(w));
|
||||||
|
|
||||||
topological_sort(acyclic_g, back_inserter(topoOrder),
|
topological_sort(acyclic_g, back_inserter(topoOrder),
|
||||||
color_map(make_iterator_property_map(colours.begin(),
|
color_map(colours));
|
||||||
get(vertex_index, acyclic_g))));
|
|
||||||
|
|
||||||
reorderSpecials(w, acyclic_g, topoOrder);
|
reorderSpecials(w, acyclic_g, topoOrder);
|
||||||
|
|
||||||
@ -443,15 +445,14 @@ unordered_map<NFAVertex, u32> assignRegions(const NGHolder &g) {
|
|||||||
const u32 numVertices = num_vertices(g);
|
const u32 numVertices = num_vertices(g);
|
||||||
DEBUG_PRINTF("assigning regions for %u vertices in holder\n", numVertices);
|
DEBUG_PRINTF("assigning regions for %u vertices in holder\n", numVertices);
|
||||||
|
|
||||||
vector<boost::default_color_type> colours(numVertices);
|
auto colours = make_small_color_map(g);
|
||||||
|
|
||||||
// Build an acyclic graph for this NGHolder.
|
// Build an acyclic graph for this NGHolder.
|
||||||
BackEdgeSet deadEdges;
|
BackEdgeSet deadEdges;
|
||||||
depth_first_search(g,
|
depth_first_search(g,
|
||||||
visitor(BackEdges<BackEdgeSet>(deadEdges))
|
visitor(BackEdges<BackEdgeSet>(deadEdges))
|
||||||
.root_vertex(g.start)
|
.root_vertex(g.start)
|
||||||
.color_map(make_iterator_property_map(colours.begin(),
|
.color_map(colours));
|
||||||
get(vertex_index, g))));
|
|
||||||
|
|
||||||
auto af = make_bad_edge_filter(&deadEdges);
|
auto af = make_bad_edge_filter(&deadEdges);
|
||||||
AcyclicGraph acyclic_g(g, af);
|
AcyclicGraph acyclic_g(g, af);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user