diff --git a/src/nfagraph/ng_region.cpp b/src/nfagraph/ng_region.cpp index 91904b46..6463a281 100644 --- a/src/nfagraph/ng_region.cpp +++ b/src/nfagraph/ng_region.cpp @@ -58,6 +58,7 @@ #include "util/container.h" #include "util/ue2_containers.h" #include "util/graph_range.h" +#include "util/graph_small_color_map.h" #include #include @@ -407,19 +408,20 @@ void liftSinks(const AcyclicGraph &acyclic_g, vector &topoOrder) { } } +using ColorMap = decltype(make_small_color_map(NGHolder())); + /** 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 * their parents. */ static vector buildTopoOrder(const NGHolder &w, const AcyclicGraph &acyclic_g, - vector &colours) { + ColorMap &colours) { vector topoOrder; topoOrder.reserve(num_vertices(w)); topological_sort(acyclic_g, back_inserter(topoOrder), - color_map(make_iterator_property_map(colours.begin(), - get(vertex_index, acyclic_g)))); + color_map(colours)); reorderSpecials(w, acyclic_g, topoOrder); @@ -443,15 +445,14 @@ unordered_map assignRegions(const NGHolder &g) { const u32 numVertices = num_vertices(g); DEBUG_PRINTF("assigning regions for %u vertices in holder\n", numVertices); - vector colours(numVertices); + auto colours = make_small_color_map(g); // Build an acyclic graph for this NGHolder. BackEdgeSet deadEdges; depth_first_search(g, visitor(BackEdges(deadEdges)) .root_vertex(g.start) - .color_map(make_iterator_property_map(colours.begin(), - get(vertex_index, g)))); + .color_map(colours)); auto af = make_bad_edge_filter(&deadEdges); AcyclicGraph acyclic_g(g, af);