From: Justin Viiret Date: Tue, 1 Dec 2015 22:54:55 +0000 (+1100) Subject: RoseDedupeAuxImpl: collect unique suffixes first X-Git-Tag: v4.1.0^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03953f34b13c38f5597c800c206998a3f8a583bc;p=thirdparty%2Fvectorscan.git RoseDedupeAuxImpl: collect unique suffixes first --- diff --git a/src/rose/rose_build_misc.cpp b/src/rose/rose_build_misc.cpp index f627017c..1d58c241 100644 --- a/src/rose/rose_build_misc.cpp +++ b/src/rose/rose_build_misc.cpp @@ -601,6 +601,8 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &tbi_in) : tbi(tbi_in) { const RoseGraph &g = tbi.g; + set suffixes; + for (auto v : vertices_range(g)) { // 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 @@ -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) { - for (const auto &report_id : all_reports(g[v].suffix)) { - suffix_map[report_id].insert(g[v].suffix); - } + suffixes.insert(g[v].suffix); + } + } + + for (const auto &suffix : suffixes) { + for (const auto &report_id : all_reports(suffix)) { + suffix_map[report_id].insert(suffix); } }