diff options
Diffstat (limited to 'compiler/rustc_data_structures/src/sso/map.rs')
| -rw-r--r-- | compiler/rustc_data_structures/src/sso/map.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_data_structures/src/sso/map.rs b/compiler/rustc_data_structures/src/sso/map.rs index 2de05cd4e56..d4274e99f1c 100644 --- a/compiler/rustc_data_structures/src/sso/map.rs +++ b/compiler/rustc_data_structures/src/sso/map.rs @@ -257,11 +257,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> { pub fn remove(&mut self, key: &K) -> Option<V> { match self { SsoHashMap::Array(array) => { - if let Some(index) = array.iter().position(|(k, _v)| k == key) { - Some(array.swap_remove(index).1) - } else { - None - } + array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index).1) } SsoHashMap::Map(map) => map.remove(key), } @@ -272,11 +268,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> { pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> { match self { SsoHashMap::Array(array) => { - if let Some(index) = array.iter().position(|(k, _v)| k == key) { - Some(array.swap_remove(index)) - } else { - None - } + array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index)) } SsoHashMap::Map(map) => map.remove_entry(key), } @@ -423,14 +415,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: &'a (K, V)) -> (&'a K, &'a V) { +fn adapt_array_ref_it<K, V>(pair: &(K, V)) -> (&K, &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: &'a mut (K, V)) -> (&'a K, &'a mut V) { +fn adapt_array_mut_it<K, V>(pair: &mut (K, V)) -> (&K, &mut V) { let (a, b) = pair; (a, b) } |
