Skip to content

Commit 80ae8ab

Browse files
committed
Use temporary variable for generic case instead for better IL
1 parent 1ed5bef commit 80ae8ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,9 @@ private static void ReverseInner<T>(ref T elements, nuint length)
594594
ref T last = ref Unsafe.Subtract(ref Unsafe.Add(ref first, (int)length), 1);
595595
do
596596
{
597-
(last, first) = (first, last);
597+
T temp = first;
598+
first = last;
599+
last = temp;
598600
first = ref Unsafe.Add(ref first, 1);
599601
last = ref Unsafe.Subtract(ref last, 1);
600602
} while (Unsafe.IsAddressLessThan(ref first, ref last));

0 commit comments

Comments
 (0)