mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
Move resize to a more sensible place
This commit is contained in:
parent
e9c56327b1
commit
86760f76ac
1 changed files with 13 additions and 9 deletions
|
@ -215,6 +215,18 @@ impl<K, V> NodeStorage<K, V> {
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn resized_to(&mut self, new_size: usize) -> Self {
|
||||||
|
let mut new_node_storage = Self::with_size(new_size);
|
||||||
|
|
||||||
|
for mut node in self.nodes.drain(..) {
|
||||||
|
if let Some((key, value, hash)) = node.take_key_value() {
|
||||||
|
new_node_storage.insert_new(key, value, hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new_node_storage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HashMap<K, V, H = BuildHasherDefault<FxHasher>>
|
pub struct HashMap<K, V, H = BuildHasherDefault<FxHasher>>
|
||||||
|
@ -255,15 +267,7 @@ impl<K, V> HashMap<K, V> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut new_node_storage = NodeStorage::with_size(new_size);
|
self.nodes = self.nodes.resized_to(new_size);
|
||||||
|
|
||||||
for mut node in self.nodes.nodes.drain(..) {
|
|
||||||
if let Some((key, value, hash)) = node.take_key_value() {
|
|
||||||
new_node_storage.insert_new(key, value, hash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.nodes = new_node_storage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue