Skip to content

Commit

Permalink
Merge pull request #73739 from sharwell/align-impl
Browse files Browse the repository at this point in the history
Align sort implementation with reference from dotnet/runtime
  • Loading branch information
sharwell committed May 28, 2024
2 parents 2d11197 + 9732adb commit 93d3cf9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
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

0 comments on commit 93d3cf9

Please sign in to comment.