bors 501b1fa594 Auto merge of #17457 - roife:remove-circle, r=Veykril
fix: ensure there are no cycles in the source_root_parent_map

See #17409

We can view the connections between roots as a graph. The problem is that this graph may contain cycles, so when adding edges, it is necessary to check whether it will lead to a cycle.

Since we ensure that each node has at most one outgoing edge (because each SourceRoot can have only one parent), we can use a disjoint-set to maintain the connectivity between nodes. If an edge’s two nodes belong to the same set, they are already connected.

Additionally, this PR includes the following three changes:

1. Removed the workaround from #17409.
2. Added an optimization: If `map.contains_key(&SourceRootId(*root_id as u32))`, we can skip the current loop iteration since we have already found its parent.
3. Modified the inner loop to iterate in reverse order with `roots[..idx].iter().rev()` at line 319. This ensures that if we are looking for the parent of `a/b/c`, and both `a` and `a/b` meet the criteria, we will choose the longer match (`a/b`).
2024-06-20 07:53:57 +00:00
..
2024-06-20 08:03:36 +03:00
2024-06-05 10:45:22 +02:00
2024-05-15 18:55:27 +02:00
2024-06-13 17:29:10 -07:00
2024-06-13 17:29:10 -07:00
2024-06-18 00:52:53 +01:00
2024-06-13 17:29:10 -07:00
2024-06-13 17:29:10 -07:00
2024-06-04 12:38:20 +02:00
2024-06-12 08:16:07 +02:00