RoseDedupeAuxImpl: collect unique suffixes first

This commit is contained in:
Justin Viiret 2015-12-02 09:54:55 +11:00 committed by Matthew Barr
parent 1267922ca7
commit 03953f34b1

View File

@ -601,6 +601,8 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &tbi_in)
: tbi(tbi_in) { : tbi(tbi_in) {
const RoseGraph &g = tbi.g; const RoseGraph &g = tbi.g;
set<suffix_id> suffixes;
for (auto v : vertices_range(g)) { for (auto v : vertices_range(g)) {
// Literals in the small block table don't count as dupes: although // Literals in the small block table don't count as dupes: although
// they have copies in the anchored table, the two are never run in the // they have copies in the anchored table, the two are never run in the
@ -611,10 +613,16 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &tbi_in)
} }
} }
// Several vertices may share a suffix, so we collect the set of
// suffixes first to avoid repeating work.
if (g[v].suffix) { if (g[v].suffix) {
for (const auto &report_id : all_reports(g[v].suffix)) { suffixes.insert(g[v].suffix);
suffix_map[report_id].insert(g[v].suffix); }
} }
for (const auto &suffix : suffixes) {
for (const auto &report_id : all_reports(suffix)) {
suffix_map[report_id].insert(suffix);
} }
} }