Skip to content

Commit

Permalink
Rollup merge of rust-lang#77471 - ssomers:btree_cleanup_3, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

BTreeMap: refactoring around edges, missed spots

Tweaks from rust-lang#77244 (and more) that are really inconsistencies in rust-lang#77005.

r? @Mark-Simulacrum
  • Loading branch information
Dylan-DPC authored Oct 5, 2020
2 parents e032bb7 + d71d13e commit 23b1e3d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
///
/// # Safety
/// The node has more than `idx` initialized elements.
pub unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
unsafe { self.reborrow_mut().into_key_mut_at(idx) }
}

/// Borrows a mutable reference to one of the values stored in the node.
///
/// # Safety
/// The node has more than `idx` initialized elements.
pub unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
unsafe { self.reborrow_mut().into_val_mut_at(idx) }
}

Expand Down Expand Up @@ -645,7 +645,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {

/// Adds a key/value pair, and an edge to go to the left of that pair,
/// to the beginning of the node.
pub fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
assert!(edge.height == self.height - 1);
assert!(self.len() < CAPACITY);

Expand Down Expand Up @@ -1001,18 +1001,18 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
let (middle_kv_idx, insertion) = splitpoint(self.idx);
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
let (mut left, k, v, mut right) = middle.split();
match insertion {
let mut insertion_edge = match insertion {
InsertionPlace::Left(insert_idx) => unsafe {
Handle::new_edge(left.reborrow_mut(), insert_idx).insert_fit(key, val, edge);
Handle::new_edge(left.reborrow_mut(), insert_idx)
},
InsertionPlace::Right(insert_idx) => unsafe {
Handle::new_edge(
right.node_as_mut().cast_unchecked::<marker::Internal>(),
insert_idx,
)
.insert_fit(key, val, edge);
},
}
};
insertion_edge.insert_fit(key, val, edge);
InsertResult::Split(SplitResult { left: left.forget_type(), k, v, right })
}
}
Expand Down

0 comments on commit 23b1e3d

Please sign in to comment.