Skip to content

Commit cf7c0dc

Browse files
committed
Auto merge of rust-lang#139696 - scottmcm:array-perf-experiment, r=<try>
experiment: tweak polymorphic array iter inlining annotations r? ghost
2 parents 1bc5618 + a81d5af commit cf7c0dc

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

library/core/src/array/iter/iter_inner.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl<T> PartialDrop for [MaybeUninit<T>] {
1919
}
2020
}
2121
impl<T, const N: usize> PartialDrop for [MaybeUninit<T>; N] {
22+
#[inline]
2223
unsafe fn partial_drop(&mut self, alive: IndexRange) {
2324
let slice: &mut [MaybeUninit<T>] = self;
2425
// SAFETY: Initialized elements in the array are also initialized in the slice.
@@ -124,7 +125,6 @@ impl<T: Clone, const N: usize> Clone for PolymorphicIter<[MaybeUninit<T>; N]> {
124125
}
125126

126127
impl<T> PolymorphicIter<[MaybeUninit<T>]> {
127-
#[inline]
128128
pub(super) fn as_slice(&self) -> &[T] {
129129
// SAFETY: We know that all elements within `alive` are properly initialized.
130130
unsafe {
@@ -133,7 +133,6 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
133133
}
134134
}
135135

136-
#[inline]
137136
pub(super) fn as_mut_slice(&mut self) -> &mut [T] {
138137
// SAFETY: We know that all elements within `alive` are properly initialized.
139138
unsafe {
@@ -157,7 +156,6 @@ impl<T: fmt::Debug> fmt::Debug for PolymorphicIter<[MaybeUninit<T>]> {
157156
/// We don't implement the actual iterator traits because we want to implement
158157
/// things like `try_fold` that require `Self: Sized` (which we're not).
159158
impl<T> PolymorphicIter<[MaybeUninit<T>]> {
160-
#[inline]
161159
pub(super) fn next(&mut self) -> Option<T> {
162160
// Get the next index from the front.
163161
//
@@ -175,13 +173,11 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
175173
})
176174
}
177175

178-
#[inline]
179176
pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
180177
let len = self.len();
181178
(len, Some(len))
182179
}
183180

184-
#[inline]
185181
pub(super) fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
186182
// This also moves the start, which marks them as conceptually "dropped",
187183
// so if anything goes bad then our drop impl won't double-free them.
@@ -197,12 +193,10 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
197193
NonZero::new(remaining).map_or(Ok(()), Err)
198194
}
199195

200-
#[inline]
201196
pub(super) fn fold<B>(&mut self, init: B, f: impl FnMut(B, T) -> B) -> B {
202197
self.try_fold(init, NeverShortCircuit::wrap_mut_2(f)).0
203198
}
204199

205-
#[inline]
206200
pub(super) fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
207201
where
208202
F: FnMut(B, T) -> R,
@@ -221,7 +215,6 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
221215
})
222216
}
223217

224-
#[inline]
225218
pub(super) fn next_back(&mut self) -> Option<T> {
226219
// Get the next index from the back.
227220
//
@@ -239,7 +232,6 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
239232
})
240233
}
241234

242-
#[inline]
243235
pub(super) fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
244236
// This also moves the end, which marks them as conceptually "dropped",
245237
// so if anything goes bad then our drop impl won't double-free them.
@@ -255,12 +247,10 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
255247
NonZero::new(remaining).map_or(Ok(()), Err)
256248
}
257249

258-
#[inline]
259250
pub(super) fn rfold<B>(&mut self, init: B, f: impl FnMut(B, T) -> B) -> B {
260251
self.try_rfold(init, NeverShortCircuit::wrap_mut_2(f)).0
261252
}
262253

263-
#[inline]
264254
pub(super) fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
265255
where
266256
F: FnMut(B, T) -> R,

0 commit comments

Comments
 (0)