Skip to content

Commit

Permalink
Attempt to address perf regressions with #[inline]
Browse files Browse the repository at this point in the history
  • Loading branch information
bstrie committed Nov 8, 2021
1 parent 3024eff commit 61b1394
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 61b1394

Please sign in to comment.