@@ -2811,11 +2811,11 @@ impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
28112811/// * perform the iteration in-place on the original allocation backing the iterator
28122812///
28132813/// The last case warrants some attention. It is an optimization that in many cases reduces peak memory
2814- /// consumption and improves cache locality. But when a large number of big, short-lived
2815- /// allocations are created, only a small fraction of their items gets collected, no further use
2816- /// is made of the spare capacity and the resulting `Vec` is moved into a longer-lived structure
2817- /// this can lead to the large allocations having their lifetimes unnecessarily extended which
2818- /// can result in increased memory footprint.
2814+ /// consumption and improves cache locality. But when big, short-lived allocations are created,
2815+ /// only a small fraction of their items gets collected, no further use is made of the spare capacity
2816+ /// and the resulting `Vec` is moved into a longer-lived structure this can lead to the large
2817+ /// allocations having their lifetimes unnecessarily extended which can result in increased memory
2818+ /// footprint.
28192819///
28202820/// In cases where this is an issue, the excess capacity can be discarded with [`Vec::shrink_to()`],
28212821/// [`Vec::shrink_to_fit()`] or by collecting into [`Box<[T]>`][owned slice] instead, which additionally reduces
@@ -2827,8 +2827,7 @@ impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
28272827/// # use std::sync::Mutex;
28282828/// static LONG_LIVED: Mutex<Vec<Vec<u16>>> = Mutex::new(Vec::new());
28292829///
2830- /// // many short-lived allocations
2831- /// for i in 0..100 {
2830+ /// for i in 0..10 {
28322831/// let big_temporary: Vec<u16> = (0..1024).collect();
28332832/// // discard most items
28342833/// let mut result: Vec<_> = big_temporary.into_iter().filter(|i| i % 100 == 0).collect();
0 commit comments