mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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.
This commit is contained in:
@@ -57,9 +57,18 @@ std::vector<std::string> 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();
|
||||
|
||||
Reference in New Issue
Block a user