Skip to content

Commit 1999fa2

Browse files
committed
Use new methods in hashbrown 0.8.1
1 parent 603c326 commit 1999fa2

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ serde = { version = "1.0", optional = true, default-features = false }
3636
rayon = { version = "1.0", optional = true }
3737

3838
[dependencies.hashbrown]
39-
version = "0.8"
39+
version = "0.8.1"
4040
default-features = false
4141
features = ["raw"]
4242

src/map/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<K, V> IndexMapCore<K, V> {
221221
debug_assert!(self.indices.capacity() >= self.entries.len());
222222
for (i, entry) in enumerate(&self.entries) {
223223
// We should never have to reallocate, so there's no need for a real hasher.
224-
self.indices.insert(entry.hash.get(), i, |_| unreachable!());
224+
self.indices.insert_no_grow(entry.hash.get(), i);
225225
}
226226
}
227227
}

src/map/core/raw.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<K, V> IndexMapCore<K, V> {
4646

4747
pub(super) fn erase_index(&mut self, hash: HashValue, index: usize) {
4848
let raw_bucket = self.find_index(hash, index).unwrap();
49-
unsafe { self.indices.erase_no_drop(&raw_bucket) };
49+
unsafe { self.indices.erase(raw_bucket) };
5050
}
5151

5252
pub(crate) fn entry(&mut self, hash: HashValue, key: K) -> Entry<K, V>
@@ -99,10 +99,7 @@ impl<K, V> IndexMapCore<K, V> {
9999
unsafe fn shift_remove_bucket(&mut self, raw_bucket: RawBucket) -> (usize, K, V) {
100100
// use Vec::remove, but then we need to update the indices that point
101101
// to all of the other entries that have to move
102-
let index = unsafe {
103-
self.indices.erase_no_drop(&raw_bucket);
104-
raw_bucket.read()
105-
};
102+
let index = unsafe { self.indices.remove(raw_bucket) };
106103
let entry = self.entries.remove(index);
107104

108105
// correct indices that point to the entries that followed the removed entry.
@@ -160,10 +157,7 @@ impl<K, V> IndexMapCore<K, V> {
160157
unsafe fn swap_remove_bucket(&mut self, raw_bucket: RawBucket) -> (usize, K, V) {
161158
// use swap_remove, but then we need to update the index that points
162159
// to the other entry that has to move
163-
let index = unsafe {
164-
self.indices.erase_no_drop(&raw_bucket);
165-
raw_bucket.read()
166-
};
160+
let index = unsafe { self.indices.remove(raw_bucket) };
167161
let entry = self.entries.swap_remove(index);
168162

169163
// correct index that points to the entry that had to swap places

0 commit comments

Comments
 (0)