Attempt to address perf regressions with #[inline]

This commit is contained in:
bstrie 2021-11-08 15:51:56 -05:00
parent 3024efff59
commit 61b1394ac7

View file

@ -331,18 +331,20 @@ impl<T: Ord, const N: usize> Ord for [T; N] {
}
#[cfg(not(bootstrap))]
#[stable(feature = "copy_clone_array_lib", since = "1.55.0")]
#[stable(feature = "copy_clone_array_lib", since = "1.58.0")]
impl<T: Copy, const N: usize> Copy for [T; N] {}
#[cfg(not(bootstrap))]
#[stable(feature = "copy_clone_array_lib", since = "1.55.0")]
#[stable(feature = "copy_clone_array_lib", since = "1.58.0")]
impl<T: Clone, const N: usize> Clone for [T; N] {
#[inline]
fn clone(&self) -> Self {
// SAFETY: we know for certain that this iterator will yield exactly `N`
// items.
unsafe { collect_into_array_unchecked(&mut self.iter().cloned()) }
}
#[inline]
fn clone_from(&mut self, other: &Self) {
self.clone_from_slice(other);
}