Auto merge of #125720 - folkertdev:optimize_for_size-ptr-rotate, r=Am… · model-checking/verify-rust-std@4aa43c7 (original) (raw)
`@@ -71,7 +71,9 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize)
`
71
71
`if (right == 0) || (left == 0) {
`
72
72
`return;
`
73
73
`}
`
74
``
`-
if (left + right < 24) || (mem::size_of::() > mem::size_of::<[usize; 4]>()) {
`
``
74
`+
if !cfg!(feature = "optimize_for_size")
`
``
75
`+
&& ((left + right < 24) || (mem::size_of::() > mem::size_of::<[usize; 4]>()))
`
``
76
`+
{
`
75
77
`// Algorithm 1
`
76
78
`// Microbenchmarks indicate that the average performance for random shifts is better all
`
77
79
`` // the way until about left + right == 32
, but the worst case performance breaks even
``
`@@ -158,7 +160,9 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize)
`
158
160
`}
`
159
161
`return;
`
160
162
`` // T
is not a zero-sized type, so it's okay to divide by its size.
``
161
``
`-
} else if cmp::min(left, right) <= mem::size_of::() / mem::size_of::() {
`
``
163
`+
} else if !cfg!(feature = "optimize_for_size")
`
``
164
`+
&& cmp::min(left, right) <= mem::size_of::() / mem::size_of::()
`
``
165
`+
{
`
162
166
`// Algorithm 2
`
163
167
`` // The [T; 0]
here is to ensure this is appropriately aligned for T
``
164
168
`let mut rawarray = MaybeUninit::<(BufType, [T; 0])>::uninit();
`