Skip to content

Commit bceae1e

Browse files
committed
Remove redundant make_insert_hash internal function
1 parent f552bdb commit bceae1e

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

src/map.rs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -260,29 +260,6 @@ where
260260
hash_builder.hash_one(val)
261261
}
262262

263-
#[cfg(not(feature = "nightly"))]
264-
#[cfg_attr(feature = "inline-more", inline)]
265-
pub(crate) fn make_insert_hash<K, S>(hash_builder: &S, val: &K) -> u64
266-
where
267-
K: Hash,
268-
S: BuildHasher,
269-
{
270-
use core::hash::Hasher;
271-
let mut state = hash_builder.build_hasher();
272-
val.hash(&mut state);
273-
state.finish()
274-
}
275-
276-
#[cfg(feature = "nightly")]
277-
#[cfg_attr(feature = "inline-more", inline)]
278-
pub(crate) fn make_insert_hash<K, S>(hash_builder: &S, val: &K) -> u64
279-
where
280-
K: Hash,
281-
S: BuildHasher,
282-
{
283-
hash_builder.hash_one(val)
284-
}
285-
286263
#[cfg(feature = "ahash")]
287264
impl<K, V> HashMap<K, V, DefaultHashBuilder> {
288265
/// Creates an empty `HashMap`.
@@ -1262,7 +1239,7 @@ where
12621239
/// ```
12631240
#[cfg_attr(feature = "inline-more", inline)]
12641241
pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S, A> {
1265-
let hash = make_insert_hash::<K, S>(&self.hash_builder, &key);
1242+
let hash = make_hash::<K, S>(&self.hash_builder, &key);
12661243
if let Some(elem) = self.table.find(hash, equivalent_key(&key)) {
12671244
Entry::Occupied(OccupiedEntry {
12681245
hash,
@@ -1782,7 +1759,7 @@ where
17821759
/// ```
17831760
#[cfg_attr(feature = "inline-more", inline)]
17841761
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
1785-
let hash = make_insert_hash::<K, S>(&self.hash_builder, &k);
1762+
let hash = make_hash::<K, S>(&self.hash_builder, &k);
17861763
let hasher = make_hasher::<_, V, S>(&self.hash_builder);
17871764
match self
17881765
.table
@@ -1849,7 +1826,7 @@ where
18491826
/// ```
18501827
#[cfg_attr(feature = "inline-more", inline)]
18511828
pub fn insert_unique_unchecked(&mut self, k: K, v: V) -> (&K, &mut V) {
1852-
let hash = make_insert_hash::<K, S>(&self.hash_builder, &k);
1829+
let hash = make_hash::<K, S>(&self.hash_builder, &k);
18531830
let bucket = self
18541831
.table
18551832
.insert(hash, (k, v), make_hasher::<_, V, S>(&self.hash_builder));
@@ -4003,7 +3980,7 @@ impl<'a, K, V, S, A: Allocator + Clone> RawVacantEntryMut<'a, K, V, S, A> {
40033980
K: Hash,
40043981
S: BuildHasher,
40053982
{
4006-
let hash = make_insert_hash::<K, S>(self.hash_builder, &key);
3983+
let hash = make_hash::<K, S>(self.hash_builder, &key);
40073984
self.insert_hashed_nocheck(hash, key, value)
40083985
}
40093986

@@ -4111,7 +4088,7 @@ impl<'a, K, V, S, A: Allocator + Clone> RawVacantEntryMut<'a, K, V, S, A> {
41114088
K: Hash,
41124089
S: BuildHasher,
41134090
{
4114-
let hash = make_insert_hash::<K, S>(self.hash_builder, &key);
4091+
let hash = make_hash::<K, S>(self.hash_builder, &key);
41154092
let elem = self.table.insert(
41164093
hash,
41174094
(key, value),
@@ -8194,7 +8171,7 @@ mod test_map {
81948171
let mut map: HashMap<_, _> = xs.iter().copied().collect();
81958172

81968173
let compute_hash = |map: &HashMap<i32, i32>, k: i32| -> u64 {
8197-
super::make_insert_hash::<i32, _>(map.hasher(), &k)
8174+
super::make_hash::<i32, _>(map.hasher(), &k)
81988175
};
81998176

82008177
// Existing key (insert)
@@ -8356,7 +8333,7 @@ mod test_map {
83568333
loop {
83578334
// occasionally remove some elements
83588335
if i < n && rng.gen_bool(0.1) {
8359-
let hash_value = super::make_insert_hash(&hash_builder, &i);
8336+
let hash_value = super::make_hash(&hash_builder, &i);
83608337

83618338
unsafe {
83628339
let e = map.table.find(hash_value, |q| q.0.eq(&i));

src/rustc_entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use self::RustcEntry::*;
2-
use crate::map::{make_insert_hash, Drain, HashMap, IntoIter, Iter, IterMut};
2+
use crate::map::{make_hash, Drain, HashMap, IntoIter, Iter, IterMut};
33
use crate::raw::{Allocator, Bucket, Global, RawTable};
44
use core::fmt::{self, Debug};
55
use core::hash::{BuildHasher, Hash};
@@ -32,7 +32,7 @@ where
3232
/// ```
3333
#[cfg_attr(feature = "inline-more", inline)]
3434
pub fn rustc_entry(&mut self, key: K) -> RustcEntry<'_, K, V, A> {
35-
let hash = make_insert_hash(&self.hash_builder, &key);
35+
let hash = make_hash(&self.hash_builder, &key);
3636
if let Some(elem) = self.table.find(hash, |q| q.0.eq(&key)) {
3737
RustcEntry::Occupied(RustcOccupiedEntry {
3838
key: Some(key),

0 commit comments

Comments
 (0)