mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Make clear faster
This commit is contained in:
parent
943fd1154f
commit
bb5bd04b5f
|
@ -254,8 +254,7 @@ impl<K, V, ALLOCATOR: ClonableAllocator> HashMap<K, V, ALLOCATOR> {
|
|||
|
||||
/// Removes all elements from the map
|
||||
pub fn clear(&mut self) {
|
||||
self.nodes =
|
||||
NodeStorage::with_size_in(self.nodes.backing_vec_size(), self.allocator().clone());
|
||||
self.nodes.clear();
|
||||
}
|
||||
|
||||
/// An iterator visiting all key-value pairs in an arbitrary order
|
||||
|
|
|
@ -210,4 +210,11 @@ impl<K, V, ALLOCATOR: ClonableAllocator> NodeStorage<K, V, ALLOCATOR> {
|
|||
|
||||
(ret, self.max_distance_to_initial_bucket as usize)
|
||||
}
|
||||
|
||||
pub(crate) fn clear(&mut self) {
|
||||
self.max_distance_to_initial_bucket = 0;
|
||||
self.number_of_items = 0;
|
||||
|
||||
self.nodes.fill_with(Node::new);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue