Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Array.Reverse<T> in ImmutableArray<T>.Builder.Reverse #82629

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,11 @@ public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer<T>?
/// </summary>
public void Reverse()
{
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
Array.Reverse<T>(_elements, 0, _count);
#else
// The non-generic Array.Reverse is not used because it does not perform
// well for non-primitive value types.
// If/when a generic Array.Reverse<T> becomes available, the below code
// can be deleted and replaced with a call to Array.Reverse<T>.
int i = 0;
int j = _count - 1;
T[] array = _elements;
Expand All @@ -934,6 +935,7 @@ public void Reverse()
i++;
j--;
}
#endif
}

/// <summary>
Expand Down