Use SSO_ARRAY_SIZE
instead of 8
in SsoHashMap
impl
This commit is contained in:
parent
0465201f77
commit
a32959263c
1 changed files with 17 additions and 17 deletions
|
@ -5,20 +5,20 @@ use std::fmt;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
|
|
||||||
// For pointer-sized arguments arrays
|
/// For pointer-sized arguments arrays
|
||||||
// are faster than set/map for up to 64
|
/// are faster than set/map for up to 64
|
||||||
// arguments.
|
/// arguments.
|
||||||
//
|
///
|
||||||
// On the other hand such a big array
|
/// On the other hand such a big array
|
||||||
// hurts cache performance, makes passing
|
/// hurts cache performance, makes passing
|
||||||
// sso structures around very expensive.
|
/// sso structures around very expensive.
|
||||||
//
|
///
|
||||||
// Biggest performance benefit is gained
|
/// Biggest performance benefit is gained
|
||||||
// for reasonably small arrays that stay
|
/// for reasonably small arrays that stay
|
||||||
// small in vast majority of cases.
|
/// small in vast majority of cases.
|
||||||
//
|
///
|
||||||
// '8' is chosen as a sane default, to be
|
/// '8' is chosen as a sane default, to be
|
||||||
// reevaluated later.
|
/// reevaluated later.
|
||||||
const SSO_ARRAY_SIZE: usize = 8;
|
const SSO_ARRAY_SIZE: usize = 8;
|
||||||
|
|
||||||
/// Small-storage-optimized implementation of a map.
|
/// Small-storage-optimized implementation of a map.
|
||||||
|
@ -407,7 +407,7 @@ where
|
||||||
|
|
||||||
impl<K, V> IntoIterator for SsoHashMap<K, V> {
|
impl<K, V> IntoIterator for SsoHashMap<K, V> {
|
||||||
type IntoIter = Either<
|
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,
|
<FxHashMap<K, V> as IntoIterator>::IntoIter,
|
||||||
>;
|
>;
|
||||||
type Item = <Self::IntoIter as Iterator>::Item;
|
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> {
|
impl<'a, K, V> IntoIterator for &'a SsoHashMap<K, V> {
|
||||||
type IntoIter = Either<
|
type IntoIter = Either<
|
||||||
std::iter::Map<
|
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),
|
fn(&'a (K, V)) -> (&'a K, &'a V),
|
||||||
>,
|
>,
|
||||||
<&'a FxHashMap<K, V> as IntoIterator>::IntoIter,
|
<&'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> {
|
impl<'a, K, V> IntoIterator for &'a mut SsoHashMap<K, V> {
|
||||||
type IntoIter = Either<
|
type IntoIter = Either<
|
||||||
std::iter::Map<
|
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),
|
fn(&'a mut (K, V)) -> (&'a K, &'a mut V),
|
||||||
>,
|
>,
|
||||||
<&'a mut FxHashMap<K, V> as IntoIterator>::IntoIter,
|
<&'a mut FxHashMap<K, V> as IntoIterator>::IntoIter,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue