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

Align sort implementation with reference from dotnet/runtime #73739

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 0 additions & 16 deletions src/Dependencies/Collections/SegmentedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,22 +394,6 @@ public static void Sort<T>(SegmentedArray<T> array, int index, int length, IComp
}
}

public static void Sort<T>(SegmentedArray<T> array, int index, int length, Comparison<T> comparison)
{
if (index < 0)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - index < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);

if (length > 1)
{
var segment = new SegmentedArraySegment<T>(array, index, length);
SegmentedArraySortHelper<T>.Sort(segment, comparison);
}
}

public static void Sort<T>(SegmentedArray<T> array, Comparison<T> comparison)
{
if (comparison is null)
Expand Down
3 changes: 2 additions & 1 deletion src/Dependencies/Collections/SegmentedList`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,8 @@ public void Sort(Comparison<T> comparison)

if (_size > 1)
{
SegmentedArray.Sort(_items, 0, _size, comparison);
var segment = new SegmentedArraySegment<T>(_items, 0, _size);
SegmentedArraySortHelper<T>.Sort(segment, comparison);
}
_version++;
}
Expand Down