CastleProto: track next top explicitly

Repeats may be removed (e.g. by pruning in role aliasing passes)
leaving "holes" in the top map. Track the next top to use explicitly,
rather than using repeats.size().
This commit is contained in:
Justin Viiret
2015-12-03 09:27:57 +11:00
committed by Matthew Barr
parent 8427d83780
commit 748d46c124
3 changed files with 32 additions and 16 deletions

View File

@@ -751,14 +751,17 @@ void pruneReportIfUnused(const RoseBuildImpl &tbi, shared_ptr<NGHolder> h,
* Castle. */
static
void pruneCastle(CastleProto &castle, ReportID report) {
for (map<u32, PureRepeat>::iterator it = castle.repeats.begin();
it != castle.repeats.end(); /* incr inside */) {
if (contains(it->second.reports, report)) {
++it;
} else {
castle.repeats.erase(it++);
unordered_set<u32> dead; // tops to remove.
for (const auto &m : castle.repeats) {
if (!contains(m.second.reports, report)) {
dead.insert(m.first);
}
}
for (const auto &top : dead) {
castle.erase(top);
}
assert(!castle.repeats.empty());
}
@@ -798,7 +801,7 @@ void pruneUnusedTops(CastleProto &castle, const RoseGraph &g,
for (u32 top : assoc_keys(castle.repeats)) {
if (!contains(used_tops, top)) {
DEBUG_PRINTF("removing unused top %u\n", top);
castle.repeats.erase(top);
castle.erase(top);
}
}
}