From b02b2098356d3f1a39a1a91a3134548364252ddb Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 31 Dec 2022 13:42:55 +0000 Subject: [PATCH] Avoid unnecessary vertex equality comparison Just avoid ever comparing a vertex to itself. --- src/api/sorting/plugin_graph.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/sorting/plugin_graph.cpp b/src/api/sorting/plugin_graph.cpp index fe3272e5..88f1ea20 100644 --- a/src/api/sorting/plugin_graph.cpp +++ b/src/api/sorting/plugin_graph.cpp @@ -576,12 +576,13 @@ void PluginGraph::AddSpecificEdges() { const auto& vertex = *vit; const auto& plugin = GetPlugin(vertex); - for (vertex_it vit2 = vit; vit2 != vitend; ++vit2) { + for (vertex_it vit2 = std::next(vit); vit2 != vitend; ++vit2) { const auto& otherVertex = *vit2; const auto& otherPlugin = GetPlugin(otherVertex); - if (plugin.IsMaster() == otherPlugin.IsMaster()) + if (plugin.IsMaster() == otherPlugin.IsMaster()) { continue; + } const auto isOtherPluginAMaster = otherPlugin.IsMaster(); vertex_t childVertex = isOtherPluginAMaster ? vertex : otherVertex;