In BTreeMap's merge function, adjust the length of the node before moving elements into it.

This commit is contained in:
Jonathan S 2016-01-19 21:07:36 -06:00
parent bff52927f5
commit 707afa2ed5

View File

@ -1022,6 +1022,8 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
}
self.node.as_leaf_mut().len -= 1;
left_node.as_leaf_mut().len += right_len as u16 + 1;
if self.node.height > 1 {
ptr::copy_nonoverlapping(
right_node.cast_unchecked().as_internal().edges.as_ptr(),
@ -1053,8 +1055,6 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
);
}
left_node.as_leaf_mut().len += right_len as u16 + 1;
Handle::new_edge(self.node, self.idx)
}
}