From 75e9dc0eb5ca660e28954a424d71ea19af8a495c Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 23 Jun 2019 07:57:14 +0100 Subject: [PATCH] Minor optimisation for adding overlap edges It's a big complexity improvement, but only shaves 0.2s off a 0.8s time with 400 plugins on my PC. --- src/api/sorting/plugin_sorter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/api/sorting/plugin_sorter.cpp b/src/api/sorting/plugin_sorter.cpp index 9105e7ea..e6047e8f 100644 --- a/src/api/sorting/plugin_sorter.cpp +++ b/src/api/sorting/plugin_sorter.cpp @@ -619,8 +619,10 @@ void PluginSorter::AddGroupEdges() { } void PluginSorter::AddOverlapEdges() { - for (const auto& vertex : - boost::make_iterator_range(boost::vertices(graph_))) { + vertex_it vit, vitend; + for (tie(vit, vitend) = boost::vertices(graph_); vit != vitend; ++vit) { + vertex_t vertex = *vit; + if (graph_[vertex].NumOverrideFormIDs() == 0) { if (logger_) { logger_->trace( @@ -631,8 +633,9 @@ void PluginSorter::AddOverlapEdges() { continue; } - for (const auto& otherVertex : - boost::make_iterator_range(boost::vertices(graph_))) { + for (vertex_it vit2 = std::next(vit); vit2 != vitend; ++vit2) { + vertex_t otherVertex = *vit2; + if (vertex == otherVertex || boost::edge(vertex, otherVertex, graph_).second || boost::edge(otherVertex, vertex, graph_).second ||