Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Stone <[email protected]>
  • Loading branch information
the8472 and cuviper authored Jan 26, 2024
1 parent e561d06 commit 29d8d40
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
///
/// # Allocation behavior
///
/// In general `Vec` does not guarantee any particular grow/allocation stategy.
/// In general `Vec` does not guarantee any particular growth or allocation strategy.
/// That also applies to this trait impl.
///
/// **Note:** This section covers implementation details and is therefore exempt from
Expand All @@ -2812,14 +2812,14 @@ impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
///
/// The last case warrants some attention. It is an optimization that in many cases reduces peak memory
/// consumption and improves cache locality. But when a large number of big, short-lived
/// allocations are created, only a small fraction of their items gets collected, no further use
/// is made of the spare capacity and the resulting `Vec` is moved into a longer-lived structure
/// allocations are created, and only a small fraction of their items get collected, no further use
/// is made of the spare capacity. If the resulting `Vec` is moved into a longer-lived structure,
/// this can lead to the large allocations having their lifetimes unnecessarily extended which
/// can result in increased memory footprint.
///
/// In cases where this is an issue the excess capacity can be discard with [`Vec::shrink_to()`],
/// [`Vec::shrink_to_fit()`] or by collecting into [`Box<[T]>`][owned slice] instead which additionally reduces
/// the size of the longlived struct.
/// In cases where this is an issue, the excess capacity can be discard with [`Vec::shrink_to()`],
/// [`Vec::shrink_to_fit()`] or by collecting into [`Box<[T]>`][owned slice] instead, which additionally reduces
/// the size of the long-lived struct.
///
/// [owned slice]: Box
///
Expand Down

0 comments on commit 29d8d40

Please sign in to comment.