Rollup merge of #74874 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeMap: define forget_type only when relevant Similar to `forget_node_type` for handles. No effect on generated code, apart maybe from the superfluous calls that might not have been optimized away. r? @Mark-Simulacrum
This commit is contained in:
commit
1033c74665
2 changed files with 16 additions and 8 deletions
|
@ -19,7 +19,7 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::E
|
|||
Ok(internal_kv) => return Ok(internal_kv),
|
||||
Err(last_edge) => match last_edge.into_node().ascend() {
|
||||
Ok(parent_edge) => parent_edge.forget_node_type(),
|
||||
Err(root) => return Err(root.forget_type()),
|
||||
Err(root) => return Err(root),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::E
|
|||
Ok(internal_kv) => return Ok(internal_kv),
|
||||
Err(last_edge) => match last_edge.into_node().ascend() {
|
||||
Ok(parent_edge) => parent_edge.forget_node_type(),
|
||||
Err(root) => return Err(root.forget_type()),
|
||||
Err(root) => return Err(root),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,12 +307,6 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
|
|||
self.height
|
||||
}
|
||||
|
||||
/// Removes any static information about whether this node is a `Leaf` or an
|
||||
/// `Internal` node.
|
||||
pub fn forget_type(self) -> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
|
||||
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
|
||||
}
|
||||
|
||||
/// Temporarily takes out another, immutable reference to the same node.
|
||||
fn reborrow(&self) -> NodeRef<marker::Immut<'_>, K, V, Type> {
|
||||
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
|
||||
|
@ -1357,6 +1351,20 @@ unsafe fn move_edges<K, V>(
|
|||
}
|
||||
}
|
||||
|
||||
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Leaf> {
|
||||
/// Removes any static information asserting that this node is a `Leaf` node.
|
||||
pub fn forget_type(self) -> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
|
||||
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
|
||||
}
|
||||
}
|
||||
|
||||
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Internal> {
|
||||
/// Removes any static information asserting that this node is an `Internal` node.
|
||||
pub fn forget_type(self) -> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
|
||||
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
|
||||
}
|
||||
}
|
||||
|
||||
impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::Edge> {
|
||||
pub fn forget_node_type(
|
||||
self,
|
||||
|
|
Loading…
Add table
Reference in a new issue