From 1999fa2534be62c9719b2381f260c131ff0aff1c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 16 Jul 2020 14:56:52 -0700 Subject: [PATCH] Use new methods in hashbrown 0.8.1 --- Cargo.toml | 2 +- src/map/core.rs | 2 +- src/map/core/raw.rs | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 915e4d28..9199733e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ serde = { version = "1.0", optional = true, default-features = false } rayon = { version = "1.0", optional = true } [dependencies.hashbrown] -version = "0.8" +version = "0.8.1" default-features = false features = ["raw"] diff --git a/src/map/core.rs b/src/map/core.rs index 22edc1e1..89c20ff7 100644 --- a/src/map/core.rs +++ b/src/map/core.rs @@ -221,7 +221,7 @@ impl IndexMapCore { debug_assert!(self.indices.capacity() >= self.entries.len()); for (i, entry) in enumerate(&self.entries) { // We should never have to reallocate, so there's no need for a real hasher. - self.indices.insert(entry.hash.get(), i, |_| unreachable!()); + self.indices.insert_no_grow(entry.hash.get(), i); } } } diff --git a/src/map/core/raw.rs b/src/map/core/raw.rs index 8d7ba82a..c06f8c33 100644 --- a/src/map/core/raw.rs +++ b/src/map/core/raw.rs @@ -46,7 +46,7 @@ impl IndexMapCore { pub(super) fn erase_index(&mut self, hash: HashValue, index: usize) { let raw_bucket = self.find_index(hash, index).unwrap(); - unsafe { self.indices.erase_no_drop(&raw_bucket) }; + unsafe { self.indices.erase(raw_bucket) }; } pub(crate) fn entry(&mut self, hash: HashValue, key: K) -> Entry @@ -99,10 +99,7 @@ impl IndexMapCore { unsafe fn shift_remove_bucket(&mut self, raw_bucket: RawBucket) -> (usize, K, V) { // use Vec::remove, but then we need to update the indices that point // to all of the other entries that have to move - let index = unsafe { - self.indices.erase_no_drop(&raw_bucket); - raw_bucket.read() - }; + let index = unsafe { self.indices.remove(raw_bucket) }; let entry = self.entries.remove(index); // correct indices that point to the entries that followed the removed entry. @@ -160,10 +157,7 @@ impl IndexMapCore { unsafe fn swap_remove_bucket(&mut self, raw_bucket: RawBucket) -> (usize, K, V) { // use swap_remove, but then we need to update the index that points // to the other entry that has to move - let index = unsafe { - self.indices.erase_no_drop(&raw_bucket); - raw_bucket.read() - }; + let index = unsafe { self.indices.remove(raw_bucket) }; let entry = self.entries.swap_remove(index); // correct index that points to the entry that had to swap places