Skip to content

Commit

Permalink
refactor: reduce some cases that don't need to update max
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds committed Mar 21, 2024
1 parent 21c8293 commit 002f2b7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/utils/src/interval_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,21 @@ where
if self.left_ref(z, Node::is_sentinel) {
x = self.node_ref(z, Node::right);
self.transplant(z, x);
self.update_max_bottom_up(self.node_ref(z, Node::parent));
} else if self.right_ref(z, Node::is_sentinel) {
x = self.node_ref(z, Node::left);
self.transplant(z, x);
self.update_max_bottom_up(self.node_ref(z, Node::parent));
} else {
y = self.tree_minimum(self.node_ref(z, Node::right));
let mut p = y;
y_orig_color = self.node_ref(y, Node::color);
x = self.node_ref(y, Node::right);
if self.node_ref(y, Node::parent) == z {
self.node_mut(x, Node::set_parent(y));
} else {
self.transplant(y, x);
p = self.node_ref(y, Node::parent);
self.node_mut(y, Node::set_right(self.node_ref(z, Node::right)));
self.right_mut(y, Node::set_parent(y));
}
Expand All @@ -280,7 +284,7 @@ where
self.left_mut(y, Node::set_parent(y));
self.node_mut(y, Node::set_color(self.node_ref(z, Node::color)));

self.update_max_bottom_up(y);
self.update_max_bottom_up(p);
}

if matches!(y_orig_color, Color::Black) {
Expand Down Expand Up @@ -587,7 +591,6 @@ where
} else {
self.parent_mut(u, Node::set_right(v));
}
self.update_max_bottom_up(self.node_ref(u, Node::parent));
}
self.node_mut(v, Node::set_parent(self.node_ref(u, Node::parent)));
}
Expand Down

0 comments on commit 002f2b7

Please sign in to comment.