From a09c9f73ac00f2669b447e6f1cf24180dbd020fa Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Mon, 19 Jul 2021 19:21:30 +0100 Subject: [PATCH] Add early check for plugin graph cycles Check after adding group edges, as after that LOOT only adds edges if they don't cause a cycle. Adding tie-break edges is the step that takes longest and scales the worst (by far), so failing before that would provide a much better user experience. --- src/api/sorting/plugin_sort.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api/sorting/plugin_sort.cpp b/src/api/sorting/plugin_sort.cpp index 46dbfcda..2db206aa 100644 --- a/src/api/sorting/plugin_sort.cpp +++ b/src/api/sorting/plugin_sort.cpp @@ -57,9 +57,18 @@ std::vector SortPlugins( groups.emplace(group.GetName(), group); } graph.AddGroupEdges(groups); + + // Check for cycles now because from this point on edges are only added if + // they don't cause cycles, and adding tie-break edges is by far the slowest + // part of the process, so if there is a cycle checking now will provide + // quicker feedback than checking later. + graph.CheckForCycles(); + graph.AddOverlapEdges(); graph.AddTieBreakEdges(); + // Check for cycles again, just in case there's a bug that lets some occur. + // The check doesn't take a significant amount of time. graph.CheckForCycles(); return graph.TopologicalSort();