Commit c8201396 authored by Luke Sandberg's avatar Luke Sandberg

improve documentation and comments to make `vade` happy

parent f35cdd0c
...@@ -146,15 +146,14 @@ pub async fn map_client_references( ...@@ -146,15 +146,14 @@ pub async fn map_client_references(
// self cycle. They don't introduce new bits anyway. // self cycle. They don't introduce new bits anyway.
&& module != *parent_module && module != *parent_module
{ {
// copy parent bits down. visit_preorder always visits parents before // copy parent bits down. `traverse_edges_from_entries_fixed_point`` always visits parents before
// children so we can assert that the parent it set. // children so we can simply assert that the parent it set.
let [Some(current), Some(parent)] = let [Some(current), Some(parent)] =
parent_modules.get_disjoint_mut([&module, parent_module]) parent_modules.get_disjoint_mut([&module, parent_module])
else { else {
unreachable!() unreachable!()
}; };
// inherit the server components from the newly observed parent. // Check if we are adding new bits and thus need to revisit children unless we are already planning to because this is a new node.
// check if we are adding new bits and thus need to revisit children unless we are already planning to because this is a new node.
if !should_visit_children { if !should_visit_children {
let len = current.len(); let len = current.len();
*current |= &*parent; *current |= &*parent;
......
...@@ -568,19 +568,18 @@ impl SingleModuleGraph { ...@@ -568,19 +568,18 @@ impl SingleModuleGraph {
/// eventual termination of the traversal. This corresponds to computing a fixed point state for /// eventual termination of the traversal. This corresponds to computing a fixed point state for
/// the graph. /// the graph.
/// ///
/// Nodes are (re)visited according to the returned priority of the node, prioritizing high /// It is guaranteed that the parent node passed to the `visit` function, if any, has
/// values. This priority is intended to be used a heuristic to reduce the number of /// already been passed to `visit`.
/// retraversals.
/// ///
/// * `entries` - The entry modules to start the traversal from /// * `entries` - The entry modules to start the traversal from
/// * `state` - The state to be passed to the callbacks /// * `state` - The state to be passed to the callbacks
/// * `visit` - Called for a specific edge /// * `visit` - Called for a specific edge
/// - Receives: (originating &SingleModuleGraphNode, edge &ChunkingType), target /// - Receives: Option(originating &SingleModuleGraphNode, edge &ChunkingType), target
/// &SingleModuleGraphNode /// &SingleModuleGraphNode
/// - Return [GraphTraversalAction]s to control the traversal /// - Return [GraphTraversalAction]s to control the traversal
/// ///
/// Returns the number of node visits (i.e. higher than the node count if there are /// Returns the number of node visits (i.e. higher than the node
/// retraversals). /// count if there are retraversals).
pub fn traverse_edges_from_entries_fixed_point<'a>( pub fn traverse_edges_from_entries_fixed_point<'a>(
&'a self, &'a self,
entries: impl IntoIterator<Item = ResolvedVc<Box<dyn Module>>>, entries: impl IntoIterator<Item = ResolvedVc<Box<dyn Module>>>,
...@@ -2001,7 +2000,7 @@ pub mod tests { ...@@ -2001,7 +2000,7 @@ pub mod tests {
} }
#[tokio::test] #[tokio::test]
async fn traverse_edges_from_entries_fixed_point_diamond() { async fn traverse_edges_from_entries_fixed_point_cycle() {
run_graph_test( run_graph_test(
vec![rcstr!("a.js")], vec![rcstr!("a.js")],
{ {
...@@ -2040,6 +2039,7 @@ pub mod tests { ...@@ -2040,6 +2039,7 @@ pub mod tests {
(Some(rcstr!("a.js")), rcstr!("b.js")), (Some(rcstr!("a.js")), rcstr!("b.js")),
(Some(rcstr!("b.js")), rcstr!("c.js")), (Some(rcstr!("b.js")), rcstr!("c.js")),
(Some(rcstr!("c.js")), rcstr!("a.js")), (Some(rcstr!("c.js")), rcstr!("a.js")),
// we start following the cycle again
(Some(rcstr!("a.js")), rcstr!("b.js")), (Some(rcstr!("a.js")), rcstr!("b.js")),
(Some(rcstr!("b.js")), rcstr!("c.js")), (Some(rcstr!("b.js")), rcstr!("c.js")),
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment