Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTreeMap: refactoring around edges, missed spots #77471

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -484,15 +484,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 @@ -655,7 +655,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 @@ -1011,18 +1011,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