Skip to content

Commit

Permalink
more refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Elmer Bulthuis committed Jul 13, 2024
1 parent 1199a46 commit c05e2ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions packages/cargo/goodrouter/src/route_node/route_node_merge.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::*;

pub fn route_node_merge<'r, K>(
parent_node_rc: RouteNodeRc<'r, K>,
child_node_rc: Option<RouteNodeRc<'r, K>>,
parent_node_rc: &RouteNodeRc<'r, K>,
child_node_rc: Option<&RouteNodeRc<'r, K>>,
anchor: &'r str,
has_parameter: bool,
route_key: Option<K>,
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn route_node_merge<'r, K>(
}

fn route_node_merge_new<'r, K>(
parent_node_rc: RouteNodeRc<'r, K>,
parent_node_rc: &RouteNodeRc<'r, K>,
anchor: &'r str,
has_parameter: bool,
route_key: Option<K>,
Expand All @@ -69,7 +69,7 @@ fn route_node_merge_new<'r, K>(
has_parameter,
route_key,
route_parameter_names,
parent: Some((&parent_node_rc).into()),
parent: Some(parent_node_rc.into()),
..Default::default()
};

Expand All @@ -81,7 +81,7 @@ fn route_node_merge_new<'r, K>(
}

fn route_node_merge_join<'r, K>(
child_node_rc: RouteNodeRc<'r, K>,
child_node_rc: &RouteNodeRc<'r, K>,
route_key: Option<K>,
route_parameter_names: Vec<&'r str>,
) -> RouteNodeRc<'r, K> {
Expand All @@ -100,8 +100,8 @@ fn route_node_merge_join<'r, K>(
}

fn route_node_merge_intermediate<'r, K>(
parent_node_rc: RouteNodeRc<'r, K>,
child_node_rc: RouteNodeRc<'r, K>,
parent_node_rc: &RouteNodeRc<'r, K>,
child_node_rc: &RouteNodeRc<'r, K>,
anchor: &'r str,
has_parameter: bool,
route_key: Option<K>,
Expand All @@ -121,7 +121,7 @@ fn route_node_merge_intermediate<'r, K>(
// remove the child from parent
{
let mut parent_node = parent_node_rc.0.borrow_mut();
parent_node.children.remove(&child_node_rc);
parent_node.children.remove(child_node_rc);
}

// create an intermediate node
Expand All @@ -131,7 +131,7 @@ fn route_node_merge_intermediate<'r, K>(
let mut intermediate_node = RouteNode {
anchor: &child_node.anchor[..common_prefix_length],
has_parameter: child_node.has_parameter,
parent: Some((&parent_node_rc).into()),
parent: Some(parent_node_rc.into()),
..Default::default()
};

Expand Down Expand Up @@ -166,8 +166,8 @@ fn route_node_merge_intermediate<'r, K>(
}

fn route_node_merge_add_to_child<'r, K>(
_parent_node_rc: RouteNodeRc<'r, K>,
child_node_rc: RouteNodeRc<'r, K>,
_parent_node_rc: &RouteNodeRc<'r, K>,
child_node_rc: &RouteNodeRc<'r, K>,
anchor: &'r str,
_has_parameter: bool,
route_key: Option<K>,
Expand All @@ -177,25 +177,25 @@ fn route_node_merge_add_to_child<'r, K>(
let anchor = &anchor[common_prefix_length..];
let has_parameter = false;

let (common_prefix_length2, child_node_rc2) = child_node_rc
let (common_prefix_length_similar, child_node_rc_similar) = child_node_rc
.0
.borrow()
.find_similar_child(anchor, has_parameter);

return route_node_merge(
child_node_rc.clone(),
child_node_rc2,
child_node_rc,
child_node_rc_similar.as_ref(),
anchor,
has_parameter,
route_key,
route_parameter_names,
common_prefix_length2,
common_prefix_length_similar,
);
}

fn route_node_merge_add_to_new<'r, K>(
parent_node_rc: RouteNodeRc<'r, K>,
child_node_rc: RouteNodeRc<'r, K>,
parent_node_rc: &RouteNodeRc<'r, K>,
child_node_rc: &RouteNodeRc<'r, K>,
anchor: &'r str,
has_parameter: bool,
route_key: Option<K>,
Expand All @@ -213,12 +213,12 @@ fn route_node_merge_add_to_new<'r, K>(

let mut parent_node = parent_node_rc.0.borrow_mut();

parent_node.children.remove(&child_node_rc);
parent_node.children.remove(child_node_rc);
parent_node.children.insert(new_node_rc.clone());

let mut new_node = new_node_rc.0.borrow_mut();
new_node.children.insert(child_node_rc.clone());
new_node.parent = Some((&parent_node_rc).into());
new_node.parent = Some(parent_node_rc.into());

let mut child_node = child_node_rc.0.borrow_mut();
child_node.anchor = &child_node.anchor[common_prefix_length..];
Expand Down
4 changes: 2 additions & 2 deletions packages/cargo/goodrouter/src/route_node/route_node_rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ impl<'r, K> RouteNodeRc<'r, K> {
.find_similar_child(anchor, has_parameter);

node_current_rc = route_node_merge(
node_current_rc,
child_node_rc,
&node_current_rc,
child_node_rc.as_ref(),
anchor,
has_parameter,
route_key,
Expand Down

0 comments on commit c05e2ce

Please sign in to comment.