diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-04-11 10:56:35 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-04-11 11:02:01 +0000 |
| commit | a32959263ca6b798fb02634d49e76c6abac41806 (patch) | |
| tree | e8fe3c2b6fa688aafc47024333ca9cfee3d140eb | |
| parent | 0465201f772bf74e57885cfa64817314ac8c743b (diff) | |
| download | rust-a32959263ca6b798fb02634d49e76c6abac41806.tar.gz rust-a32959263ca6b798fb02634d49e76c6abac41806.zip | |
Use `SSO_ARRAY_SIZE` instead of `8` in `SsoHashMap` impl
| -rw-r--r-- | compiler/rustc_data_structures/src/sso/map.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/compiler/rustc_data_structures/src/sso/map.rs b/compiler/rustc_data_structures/src/sso/map.rs index f9e2dfd16d5..89b8c852649 100644 --- a/compiler/rustc_data_structures/src/sso/map.rs +++ b/compiler/rustc_data_structures/src/sso/map.rs @@ -5,20 +5,20 @@ use std::fmt; use std::hash::Hash; use std::ops::Index; -// For pointer-sized arguments arrays -// are faster than set/map for up to 64 -// arguments. -// -// On the other hand such a big array -// hurts cache performance, makes passing -// sso structures around very expensive. -// -// Biggest performance benefit is gained -// for reasonably small arrays that stay -// small in vast majority of cases. -// -// '8' is chosen as a sane default, to be -// reevaluated later. +/// For pointer-sized arguments arrays +/// are faster than set/map for up to 64 +/// arguments. +/// +/// On the other hand such a big array +/// hurts cache performance, makes passing +/// sso structures around very expensive. +/// +/// Biggest performance benefit is gained +/// for reasonably small arrays that stay +/// small in vast majority of cases. +/// +/// '8' is chosen as a sane default, to be +/// reevaluated later. const SSO_ARRAY_SIZE: usize = 8; /// Small-storage-optimized implementation of a map. @@ -407,7 +407,7 @@ where impl<K, V> IntoIterator for SsoHashMap<K, V> { type IntoIter = Either< - <ArrayVec<(K, V), 8> as IntoIterator>::IntoIter, + <ArrayVec<(K, V), SSO_ARRAY_SIZE> as IntoIterator>::IntoIter, <FxHashMap<K, V> as IntoIterator>::IntoIter, >; type Item = <Self::IntoIter as Iterator>::Item; @@ -437,7 +437,7 @@ fn adapt_array_mut_it<K, V>(pair: &mut (K, V)) -> (&K, &mut V) { impl<'a, K, V> IntoIterator for &'a SsoHashMap<K, V> { type IntoIter = Either< std::iter::Map< - <&'a ArrayVec<(K, V), 8> as IntoIterator>::IntoIter, + <&'a ArrayVec<(K, V), SSO_ARRAY_SIZE> as IntoIterator>::IntoIter, fn(&'a (K, V)) -> (&'a K, &'a V), >, <&'a FxHashMap<K, V> as IntoIterator>::IntoIter, @@ -455,7 +455,7 @@ impl<'a, K, V> IntoIterator for &'a SsoHashMap<K, V> { impl<'a, K, V> IntoIterator for &'a mut SsoHashMap<K, V> { type IntoIter = Either< std::iter::Map< - <&'a mut ArrayVec<(K, V), 8> as IntoIterator>::IntoIter, + <&'a mut ArrayVec<(K, V), SSO_ARRAY_SIZE> as IntoIterator>::IntoIter, fn(&'a mut (K, V)) -> (&'a K, &'a mut V), >, <&'a mut FxHashMap<K, V> as IntoIterator>::IntoIter, |
