Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov"
The PR had some unforseen perf regressions that are not as easy to find. Revert the PR for now. This reverts commit6ae8912a3e, reversing changes made to86d6d2b738.
This commit is contained in:
@@ -257,7 +257,11 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
|
||||
pub fn remove(&mut self, key: &K) -> Option<V> {
|
||||
match self {
|
||||
SsoHashMap::Array(array) => {
|
||||
array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index).1)
|
||||
if let Some(index) = array.iter().position(|(k, _v)| k == key) {
|
||||
Some(array.swap_remove(index).1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
SsoHashMap::Map(map) => map.remove(key),
|
||||
}
|
||||
@@ -268,7 +272,11 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
|
||||
pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> {
|
||||
match self {
|
||||
SsoHashMap::Array(array) => {
|
||||
array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index))
|
||||
if let Some(index) = array.iter().position(|(k, _v)| k == key) {
|
||||
Some(array.swap_remove(index))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
SsoHashMap::Map(map) => map.remove_entry(key),
|
||||
}
|
||||
@@ -415,14 +423,14 @@ impl<K, V> IntoIterator for SsoHashMap<K, V> {
|
||||
|
||||
/// adapts Item of array reference iterator to Item of hashmap reference iterator.
|
||||
#[inline(always)]
|
||||
fn adapt_array_ref_it<K, V>(pair: &(K, V)) -> (&K, &V) {
|
||||
fn adapt_array_ref_it<K, V>(pair: &'a (K, V)) -> (&'a K, &'a V) {
|
||||
let (a, b) = pair;
|
||||
(a, b)
|
||||
}
|
||||
|
||||
/// adapts Item of array mut reference iterator to Item of hashmap mut reference iterator.
|
||||
#[inline(always)]
|
||||
fn adapt_array_mut_it<K, V>(pair: &mut (K, V)) -> (&K, &mut V) {
|
||||
fn adapt_array_mut_it<K, V>(pair: &'a mut (K, V)) -> (&'a K, &'a mut V) {
|
||||
let (a, b) = pair;
|
||||
(a, b)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ impl<T> SsoHashSet<T> {
|
||||
/// An iterator visiting all elements in arbitrary order.
|
||||
/// The iterator element type is `&'a T`.
|
||||
#[inline]
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
pub fn iter(&'a self) -> impl Iterator<Item = &'a T> {
|
||||
self.into_iter()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user