ng_dominators: use a vector for doms internally

This commit is contained in:
Justin Viiret 2017-03-13 15:18:12 +11:00 committed by Matthew Barr
parent 5005d50050
commit 8a6b38a9b5

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2016, Intel Corporation * Copyright (c) 2015-2017, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -62,8 +62,8 @@ unordered_map<NFAVertex, NFAVertex> calcDominators(const Graph &g,
vector<Vertex> vertices_by_dfnum(num_verts, Graph::null_vertex()); vector<Vertex> vertices_by_dfnum(num_verts, Graph::null_vertex());
// Output map. // Output map.
unordered_map<Vertex, Vertex> doms; vector<Vertex> doms(num_verts, Graph::null_vertex());
auto dom_map = make_assoc_property_map(doms); auto dom_map = make_iterator_property_map(doms.begin(), index_map);
boost_ue2::lengauer_tarjan_dominator_tree(g, source, index_map, dfnum_map, boost_ue2::lengauer_tarjan_dominator_tree(g, source, index_map, dfnum_map,
parent_map, vertices_by_dfnum, parent_map, vertices_by_dfnum,
@ -71,10 +71,12 @@ unordered_map<NFAVertex, NFAVertex> calcDominators(const Graph &g,
/* Translate back to an NFAVertex map */ /* Translate back to an NFAVertex map */
unordered_map<NFAVertex, NFAVertex> doms2; unordered_map<NFAVertex, NFAVertex> doms2;
for (const auto &e : doms) { doms2.reserve(num_verts);
NFAVertex f(e.first); for (auto v : vertices_range(g)) {
NFAVertex s(e.second); auto dom_of_v = doms[g[v].index];
doms2[f] = s; if (dom_of_v) {
doms2.emplace(v, dom_of_v);
}
} }
return doms2; return doms2;
} }