Skip to content

Commit a329592

Browse files
committed
Use SSO_ARRAY_SIZE instead of 8 in SsoHashMap impl
1 parent 0465201 commit a329592

File tree

1 file changed

+17
-17
lines changed
  • compiler/rustc_data_structures/src/sso

1 file changed

+17
-17
lines changed

compiler/rustc_data_structures/src/sso/map.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ use std::fmt;
55
use std::hash::Hash;
66
use std::ops::Index;
77

8-
// For pointer-sized arguments arrays
9-
// are faster than set/map for up to 64
10-
// arguments.
11-
//
12-
// On the other hand such a big array
13-
// hurts cache performance, makes passing
14-
// sso structures around very expensive.
15-
//
16-
// Biggest performance benefit is gained
17-
// for reasonably small arrays that stay
18-
// small in vast majority of cases.
19-
//
20-
// '8' is chosen as a sane default, to be
21-
// reevaluated later.
8+
/// For pointer-sized arguments arrays
9+
/// are faster than set/map for up to 64
10+
/// arguments.
11+
///
12+
/// On the other hand such a big array
13+
/// hurts cache performance, makes passing
14+
/// sso structures around very expensive.
15+
///
16+
/// Biggest performance benefit is gained
17+
/// for reasonably small arrays that stay
18+
/// small in vast majority of cases.
19+
///
20+
/// '8' is chosen as a sane default, to be
21+
/// reevaluated later.
2222
const SSO_ARRAY_SIZE: usize = 8;
2323

2424
/// Small-storage-optimized implementation of a map.
@@ -407,7 +407,7 @@ where
407407

408408
impl<K, V> IntoIterator for SsoHashMap<K, V> {
409409
type IntoIter = Either<
410-
<ArrayVec<(K, V), 8> as IntoIterator>::IntoIter,
410+
<ArrayVec<(K, V), SSO_ARRAY_SIZE> as IntoIterator>::IntoIter,
411411
<FxHashMap<K, V> as IntoIterator>::IntoIter,
412412
>;
413413
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) {
437437
impl<'a, K, V> IntoIterator for &'a SsoHashMap<K, V> {
438438
type IntoIter = Either<
439439
std::iter::Map<
440-
<&'a ArrayVec<(K, V), 8> as IntoIterator>::IntoIter,
440+
<&'a ArrayVec<(K, V), SSO_ARRAY_SIZE> as IntoIterator>::IntoIter,
441441
fn(&'a (K, V)) -> (&'a K, &'a V),
442442
>,
443443
<&'a FxHashMap<K, V> as IntoIterator>::IntoIter,
@@ -455,7 +455,7 @@ impl<'a, K, V> IntoIterator for &'a SsoHashMap<K, V> {
455455
impl<'a, K, V> IntoIterator for &'a mut SsoHashMap<K, V> {
456456
type IntoIter = Either<
457457
std::iter::Map<
458-
<&'a mut ArrayVec<(K, V), 8> as IntoIterator>::IntoIter,
458+
<&'a mut ArrayVec<(K, V), SSO_ARRAY_SIZE> as IntoIterator>::IntoIter,
459459
fn(&'a mut (K, V)) -> (&'a K, &'a mut V),
460460
>,
461461
<&'a mut FxHashMap<K, V> as IntoIterator>::IntoIter,

0 commit comments

Comments
 (0)