perf(cutting): build finished ordinals once per search expansion

The readiness filter rebuilt the finished-part list for every candidate.
Build one set per expanded node; the candidates and their order are
unchanged.
This commit is contained in:
aj committed 2026-10-05 00:29:47 -04:00
1 parent 1d8c5fe274
commit b8afcc6fdd
1 file changed
+3 -2
@@ -58,9 +58,10 @@ internal static class JointCuttingPlanSearch
IEnumerable<Edge> Expand(Node node)
{
var finished = node.Order.Select(o => o.SourceOrdinal).ToHashSet();
var sources = node.Active is { } active ? new[] { active.Source }
: snapshot.Placements.Where(p => !node.Order.Any(o => o.SourceOrdinal == p.SourceOrdinal)
&& snapshot.Dependencies.IsReady(p.SourceOrdinal, node.Order.Select(o => o.SourceOrdinal).ToArray())
: snapshot.Placements.Where(p => !finished.Contains(p.SourceOrdinal)
&& snapshot.Dependencies.IsReady(p.SourceOrdinal, finished)
&& (!snapshot.PreservePartOrder || p.SourceOrdinal == node.Order.Length));
foreach (var source in sources)
{