Skip to content

Commit 5e11d32

Browse files
author
Markus Westerlind
committed
nits
1 parent d8463d0 commit 5e11d32

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/map.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub(crate) fn make_hasher<K: Hash, V>(
218218
/// Ensures that a single closure type across uses of this which, in turn prevents multiple
219219
/// instances of any functions like RawTable::reserve from being generated
220220
#[cfg_attr(feature = "inline-more", inline)]
221-
fn equivalent<Q, K, V>(k: &Q) -> impl Fn(&(K, V)) -> bool + '_
221+
fn equivalent_key<Q, K, V>(k: &Q) -> impl Fn(&(K, V)) -> bool + '_
222222
where
223223
K: Borrow<Q>,
224224
Q: ?Sized + Eq,
@@ -229,7 +229,7 @@ where
229229
/// Ensures that a single closure type across uses of this which, in turn prevents multiple
230230
/// instances of any functions like RawTable::reserve from being generated
231231
#[cfg_attr(feature = "inline-more", inline)]
232-
fn equivalent_single<Q, K>(k: &Q) -> impl Fn(&K) -> bool + '_
232+
fn equivalent<Q, K>(k: &Q) -> impl Fn(&K) -> bool + '_
233233
where
234234
K: Borrow<Q>,
235235
Q: ?Sized + Eq,
@@ -792,7 +792,7 @@ where
792792
#[cfg_attr(feature = "inline-more", inline)]
793793
pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S> {
794794
let hash = make_hash(&self.hash_builder, &key);
795-
if let Some(elem) = self.table.find(hash, equivalent(&key)) {
795+
if let Some(elem) = self.table.find(hash, equivalent_key(&key)) {
796796
Entry::Occupied(OccupiedEntry {
797797
hash,
798798
key: Some(key),
@@ -879,7 +879,7 @@ where
879879
Q: Hash + Eq,
880880
{
881881
let hash = make_hash(&self.hash_builder, k);
882-
self.table.get(hash, equivalent(k))
882+
self.table.get(hash, equivalent_key(k))
883883
}
884884

885885
/// Returns the key-value pair corresponding to the supplied key, with a mutable reference to value.
@@ -987,7 +987,7 @@ where
987987
Q: Hash + Eq,
988988
{
989989
let hash = make_hash(&self.hash_builder, k);
990-
self.table.get_mut(hash, equivalent(k))
990+
self.table.get_mut(hash, equivalent_key(k))
991991
}
992992

993993
/// Inserts a key-value pair into the map.
@@ -1018,7 +1018,7 @@ where
10181018
#[cfg_attr(feature = "inline-more", inline)]
10191019
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
10201020
let hash = make_hash(&self.hash_builder, &k);
1021-
if let Some((_, item)) = self.table.get_mut(hash, equivalent(&k)) {
1021+
if let Some((_, item)) = self.table.get_mut(hash, equivalent_key(&k)) {
10221022
Some(mem::replace(item, v))
10231023
} else {
10241024
self.table
@@ -1087,7 +1087,7 @@ where
10871087
Q: Hash + Eq,
10881088
{
10891089
let hash = make_hash(&self.hash_builder, &k);
1090-
self.table.remove_entry(hash, equivalent(k))
1090+
self.table.remove_entry(hash, equivalent_key(k))
10911091
}
10921092
}
10931093

@@ -1554,7 +1554,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> {
15541554
K: Borrow<Q>,
15551555
Q: Eq,
15561556
{
1557-
self.from_hash(hash, equivalent_single(k))
1557+
self.from_hash(hash, equivalent(k))
15581558
}
15591559
}
15601560

@@ -1611,7 +1611,7 @@ impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> {
16111611
K: Borrow<Q>,
16121612
Q: Eq,
16131613
{
1614-
self.from_hash(hash, equivalent_single(k))
1614+
self.from_hash(hash, equivalent(k))
16151615
}
16161616

16171617
#[cfg_attr(feature = "inline-more", inline)]
@@ -2001,17 +2001,18 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
20012001
K: Hash,
20022002
S: BuildHasher,
20032003
{
2004-
let hash_builder = self.hash_builder;
2005-
let mut hasher = hash_builder.build_hasher();
2004+
let mut hasher = self.hash_builder.build_hasher();
20062005
key.hash(&mut hasher);
20072006

2008-
let elem = self
2009-
.table
2010-
.insert(hasher.finish(), (key, value), make_hasher(hash_builder));
2007+
let elem = self.table.insert(
2008+
hasher.finish(),
2009+
(key, value),
2010+
make_hasher(self.hash_builder),
2011+
);
20112012
RawOccupiedEntryMut {
20122013
elem,
20132014
table: self.table,
2014-
hash_builder,
2015+
hash_builder: self.hash_builder,
20152016
}
20162017
}
20172018
}

0 commit comments

Comments
 (0)