From 6be8b63cf07c99c81c54963be51b2eda44b674c7 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sat, 12 Jul 2014 13:17:40 +0100 Subject: [PATCH] Fixed unnecessary vertices in forward-cycles. Related to #188. --- src/backend/graph.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/graph.cpp b/src/backend/graph.cpp index 96a19650..bd9f49ec 100644 --- a/src/backend/graph.cpp +++ b/src/backend/graph.cpp @@ -45,7 +45,18 @@ namespace loot { void cycle_detector::tree_edge(edge_t e, const PluginGraph& g) { vertex_t source = boost::source(e, g); - trail.push_back(g[source].Name()); + string name = g[source].Name(); + + // Check if the plugin already exists in the recorded trail. + auto it = find(trail.begin(), trail.end(), name); + + if (it != trail.end()) { + // Erase everything from this position onwards, as it doesn't + // contribute to a forward-cycle. + trail.erase(it, trail.end()); + } + + trail.push_back(name); } void cycle_detector::back_edge(edge_t e, const PluginGraph& g) {